Ejemplo n.º 1
0
        public static bool Login(string username, string pwd, string machineName)
        {
            var localmachine = MachineLogic.localMachine();
            var logininf     = new loginInfo
            {
                pwd         = pwd,
                machineName = machineName,
                username    = username
            };

            if (localmachine.username == username)
            {
                logininf.machineId = localmachine.machineId;
            }

            var url   = ServerAddrs.lylApiServerAddr + "api/user/login";
            var token = HTTPRuqest.LYLPost <string>(url, logininf);
            //
            var usermachine = AutoLogin(token);

            localmachine.machineName = usermachine.machineName;
            localmachine.username    = username;
            localmachine.machinepwd  = usermachine.machinePwd;
            localmachine.token       = token;
            localmachine.machineId   = usermachine.machineId;
            MachineLogic.RecordMachineInfo(localmachine);
            return(true);
        }
Ejemplo n.º 2
0
        public static string ApplyPlay()
        {
            var url     = ServerAddrs.lylApiServerAddr + "api/videoPlay/createPlay";
            var headers = new Dictionary <string, string>();

            headers.Add("token", MachineLogic.localMachine().token);
            return(HTTPRuqest.LYLPost <string>(url, null, headers));
        }
Ejemplo n.º 3
0
        ///***************************************************
        ///
        public static void SendMessage(string remoteMachineId, object content, msgType msgtype)
        {
            websocketMsgTemp <object> data = new websocketMsgTemp <object>();

            data.senderId   = MachineLogic.localMachine().machineId;
            data.receiverId = remoteMachineId;
            data.msgType    = msgtype;
            data.content    = content;
            wsclient.Send(JsonConvert.SerializeObject(data));
        }
Ejemplo n.º 4
0
 public WebSocketClient()
 {
     if (wsclient == null)
     {
         var machineInfo = MachineLogic.localMachine();
         wsclient = new WebSocket(ServerAddrs.lylWebSocketAddr + "?token=" + machineInfo.token);
     }
     wsclient.EmitOnPing = true;
     wsclient.OnMessage += Wsclient_OnMessage;
     wsclient.OnClose   += Wsclient_OnClose;
     wsclient.OnError   += Wsclient_OnError;
     wsclient.OnOpen    += Wsclient_OnOpen;
 }