コード例 #1
0
 private void Connect()
 {
     if (Connected == CONNECTSTATUS.DISCONNECTED)
     {
         this.logger.Write(Log.common.enums.TYPE.INFO, Messager.MSG_SOCKET_CONNECTING);
         Connected = CONNECTSTATUS.CONNECTING;
         Socket.Connect();
     }
 }
コード例 #2
0
        private void OnMessage(object sender, MessageEventArgs e)
        {
            var command = Commander.Deserialize(e.Data);

            if (command != null)
            {
                switch (command.COMMAND)
                {
                case COMMAND.KEY:
                    key = command.Requestor.ID;
                    Commander.Initial(key);
                    this.logger.Write(Log.common.enums.TYPE.INFO, string.Format("key:{0}", key));
                    Login();
                    Connected = CONNECTSTATUS.CONNECTED;
                    break;

                case COMMAND.LOGIN:
                    var status = Convert.ToInt32(command.Parameters["status"]);
                    if (status == 2)
                    {
                        user        = command.Requestor;
                        LoginStatus = LOGINSTATUS.LOGIN;
                        this.logger.Write(Log.common.enums.TYPE.INFO, string.Format(Messager.MSG_SOCKET_LOGIN_OK, user.NickName));
                    }
                    else
                    {
                        LoginStatus = LOGINSTATUS.LOGOUT;
                        this.logger.Write(Log.common.enums.TYPE.INFO, string.Format(Messager.MSG_SOCKET_LOGIN_NG, status));
                    }
                    break;

                case COMMAND.SG:
                    var sgcmd = SGCommand.ConvertFromCommand(command);
                    if (sgcmd != null)
                    {
                        CommandQueue.Enqueue(sgcmd);
                    }
                    else
                    {
                        SendCommand(MakeMSGCommand(command.Requestor.ID, Messager.MSG_SOCKET_BAD_COMMAND));
                    }
                    break;
                }
            }
        }
コード例 #3
0
 private void OnClose(object sender, CloseEventArgs e)
 {
     Connected = CONNECTSTATUS.DISCONNECTED;
     this.logger.Write(Log.common.enums.TYPE.INFO, Messager.MSG_SOCKET_CLOSED);
 }