Пример #1
0
        iMsg Data_Command(object sender, cMsg Args)
        {
            iMsg             sReturn    = null;
            WebsocketHandler Connection = (WebsocketHandler)sender;

            if (Received == null)
            {
                return(null);
            }
            if (Connection == null)
            {
                return(null);
            }

            try
            {
                sReturn = Received(Connection, Connection.Peer, Args);
            }
            catch (Exception ex)
            {
                string sLine = "Server.Err: " + ex.Message;

                Write(sLine);

                sReturn = new sMsg("error", sLine);
            }

            return(sReturn);
        }
Пример #2
0
        private void Data_Command(object sender, cMsg Args)
        {
            iMsg             sReturn    = null;
            WebsocketHandler Connection = (WebsocketHandler)sender;

            if (Command == null)
            {
                return;
            }
            if (Connection == null)
            {
                return;
            }

            try
            {
                sReturn = Command(Connection, Args);
            }
            catch (Exception ex)
            {
                sReturn = new sMsg("error", ex.Message);
            }

            if (Connection != null)
            {
                Connection.Send(sReturn);
            }
        }
Пример #3
0
        internal void RaiseConnection()
        {
            iMsg sData = Connection(this, new EventArgs());

            Connection = null;

            Send(sData);
        }
Пример #4
0
        public void Send(iMsg Payload)
        {
            if (Payload == null)
            {
                return;
            }

            switch (Payload.type)
            {
            case "logout":
            {
                if (SendedQuit)
                {
                    return;
                }
                if (Payload == null)
                {
                    return;
                }

                SendedQuit = true;

                Send(Payload.Serialize());
                return;
            }

            case "error":
            case "reboot":
            {
                Send(Payload.Serialize());
                return;
            }
            }

            Send(Payload.Serialize());
        }
Пример #5
0
 public MsgArgs(iMsg Message)
 {
     this.Message = Message;
 }