Esempio n. 1
0
        public void SuperSocket_DataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
        {
            var code = SerializaHelper.DeSerialize <CodeBase>(e.Data);

            if (code == null)
            {
                Mediator.ShowMsg("无法处理的未知消息类型");
            }
            if (code.Name == "Regist")
            {
                var registCode = code as RegistCode;
                File.WriteAllText(Path.Combine(Application.StartupPath, "appLicense.txt"), registCode.License);
                if (!registCode.isLegal)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        this.Title            = "身份验证过期!,请重新激活此软件";
                        this.BtnText          = "确定";
                        this.CancelBtnVisible = true;
                        this.btnCancel.Click += (a, b) => { System.Environment.Exit(0); };
                    }));
                }
                else
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        //this.Title = "身份验证通过...";
                        //this.BtnText = "确定";
                        //this.CancelBtnVisible = true;
                        this.Close();
                    }));
                }
            }
        }
Esempio n. 2
0
 private void WebSocket_OnData(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     messages.Enqueue(new QueuedWebSocketMessage {
         Data = e.Data, IsBinary = true
     });
     messageEvent.Set();
 }
Esempio n. 3
0
 void HandleDataReceivedReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     if (Message != null)
     {
         Message(sender, new TransportMessageEventArgs(e.Data));
     }
 }
 private void OnWsDataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     if (null != m_AsyncActionQueue)
     {
         m_AsyncActionQueue.QueueActionWithDelegation((MyAction <byte[]>) this.OnDataReceived, e.Data);
     }
 }
Esempio n. 5
0
 void SuperSocket_DataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     try
     {
         var code = SerializaHelper.DeSerialize <CodeBase>(e.Data);
         if (code == null)
         {
             ShowMsg("无法处理的未知消息类型");
         }
         //消息分发处理
         var interFaces = this.GetType().GetInterfaces().Where(iface => iface.Name == "IHandleMessage`1");
         foreach (var interFace in interFaces)
         {
             var codeType = code.GetType();
             var argTypes = interFace.GetGenericArguments();
             if (argTypes != null && argTypes.Length == 1 && argTypes[0].Name == codeType.Name)
             {
                 System.Reflection.MethodInfo methodInfo = interFace.GetMethod("HandleMessage");
                 var result = methodInfo.Invoke(this, new object[] { code });
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 6
0
 void SuperSocket_DataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     try
     {
         var code = SerializaHelper.DeSerialize <CodeBase>(e.Data);
         if (code == null)
         {
             Mediator.ShowMsg("无法处理的未知消息类型");
         }
         //消息分发处理
         for (int i = 0; i < Application.OpenForms.Count; i++)
         {
             var from       = Application.OpenForms[i];
             var interFaces = from.GetType().GetInterfaces().Where(iface => iface.Name == "IHandleMessage`1");
             // var interFace = from.GetType().GetInterface("IHandleMessage`1");
             foreach (var interFace in interFaces)
             {
                 var codeType = code.GetType();
                 var argTypes = interFace.GetGenericArguments();
                 if (argTypes != null && argTypes.Length == 1 && argTypes[0].Name == codeType.Name)
                 {
                     System.Reflection.MethodInfo methodInfo = interFace.GetMethod("HandleMessage");
                     var result = methodInfo.Invoke(from, new object[] { code });
                 }
             }
         }
     }
     catch
     {
     }
 }
Esempio n. 7
0
 private void OnDataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     LogSystem.Info("Receive Data Message:\n{0}", Helper.BinToHex(e.Data));
 }
Esempio n. 8
0
 private void SocketClient_DataReceived(object sender, WebSocket4Net.DataReceivedEventArgs e)
 {
     AppendInfo($"【服务消息】: SocketClient_DataReceived");
 }
Esempio n. 9
0
        void OnReceiveHandler(BinaryRequestInfo package)
        {
            var e = new WebSocket4Net.DataReceivedEventArgs(package.Data);

            OnDataReceived(e);
        }