瀏覽代碼

test: enable check token

lijian 2 年之前
父節點
當前提交
4646fd2335
共有 2 個文件被更改,包括 11 次插入12 次删除
  1. 1 2
      pkg/mqtt/connection.go
  2. 10 10
      services/mqttaccess/mqtt_provider.go

+ 1 - 2
pkg/mqtt/connection.go

@@ -87,7 +87,7 @@ func (c *Connection) Publish(msg Message, timeout time.Duration) error {
 		<-timer.C
 		waitCh, exist := c.MessageWaitChan[message.MessageID]
 		if exist {
-			waitCh <- errors.New("timeout pushlishing message")
+			waitCh <- errors.New("timeout publishing message")
 			delete(c.MessageWaitChan, message.MessageID)
 			close(waitCh)
 		}
@@ -329,7 +329,6 @@ func (c *Connection) SendMsgToClient() {
 				server.Log.Errorf("%s is end now", host)
 				return
 			}
-			server.Log.Debugf("send msg to %s=======\n%v\n=========", host, msg)
 			err := msg.Encode(c.Conn)
 			if err != nil {
 				server.Log.Errorf("send msg err: %s=====\n%v\n=====", err, msg)

+ 10 - 10
services/mqttaccess/mqtt_provider.go

@@ -16,16 +16,16 @@ func NewMQTTProvider() *MQTTProvider {
 }
 
 func (mp *MQTTProvider) ValidateDeviceToken(deviceid string, token []byte) error {
-	//args := rpcs.ArgsValidateDeviceAccessToken{
-	//	Id:          deviceid,
-	//	AccessToken: token,
-	//}
-	//reply := rpcs.ReplyValidateDeviceAccessToken{}
-	//err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.ValidateDeviceAccessToken", args, &reply)
-	//if err != nil {
-	//	server.Log.Errorf("validate device token error. deviceid : %v, token : %v, error: %v", deviceid, token, err)
-	//	return err
-	//}
+	args := rpcs.ArgsValidateDeviceAccessToken{
+		Id:          deviceid,
+		AccessToken: token,
+	}
+	reply := rpcs.ReplyValidateDeviceAccessToken{}
+	err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.ValidateDeviceAccessToken", args, &reply)
+	if err != nil {
+		server.Log.Errorf("validate device token error. deviceid : %v, token : %v, error: %v", deviceid, token, err)
+		return err
+	}
 	return nil
 }
 func (mp *MQTTProvider) OnDeviceOnline(args rpcs.ArgsGetOnline, VendorId string) error {