コード例 #1
0
 public void StartKeepAlive()
 {
     Console.WriteLine(this + " StartKeepAlive");
     System.Threading.Timer keepalive = new System.Threading.Timer((object e) =>
     {
         CPacket _packet = CPacket.Create(0);
         _packet.WriteInt(0);
         SendCode(_packet);
     }, null, 0, 3000);
 }
コード例 #2
0
ファイル: CUserToken.cs プロジェクト: ngkang917/Minos
        public void close()
        {
            // 중복 수행을 막는다.
            if (Interlocked.CompareExchange(ref this.is_closed, 1, 0) == 1)
            {
                return;
            }

            if (this.current_state == State.Closed)
            {
                // already closed.
                return;
            }

            this.current_state = State.Closed;
            this.socket.Close();
            this.socket = null;

            this.send_event_args.UserToken    = null;
            this.receive_event_args.UserToken = null;

            this.sending_list.Clear();
            this.message_resolver.clear_buffer();

            if (this.peer != null)
            {
                CPacket msg = CPacket.Create((ushort)CUserToken.SYS_CLOSE_ACK);
                if (this.dispatcher != null)
                {
                    this.dispatcher.on_message(this, new ArraySegment <byte>(msg.Buffer, 0, msg.Position));
                }
                else
                {
                    on_message(msg);
                }
            }
        }
コード例 #3
0
ファイル: CUserToken.cs プロジェクト: ngkang917/Minos
        /// <summary>
        /// 종료코드를 전송하여 상대방이 먼저 끊도록 한다.
        /// </summary>
        void byebye()
        {
            CPacket bye = CPacket.Create(SYS_CLOSE_REQ);

            send(bye);
        }
コード例 #4
0
        void send()
        {
            CPacket msg = CPacket.Create((ushort)CUserToken.SYS_UPDATE_HEARTBEAT);

            this.server.send(msg);
        }