void IUserState.on_message(FreeNet.CPacket msg)
        {
            PROTOCOL protocol = (PROTOCOL)msg.pop_protocol_id();

            switch (protocol)
            {
            case PROTOCOL.ENTER_GAME_ROOM_REQ:
                Program.game_main.matching_req(this.owner);
                break;

            case PROTOCOL.ENTER_GAME_ROOM_REQ2:
                Program.game_main.matching_req2(this.owner);
                break;

            case PROTOCOL.ENTER_GAME_ROOM_REQ3:
                invite_room_start(msg);
                break;

            case PROTOCOL.INVITE_ROOM_CREATE:     //친구초대방 생성
                Program.game_main.matching_req3(this.owner);
                this.owner.battle_room.board = msg.pop_int32();
                this.owner.battle_room.invite_room_check.Add(this.owner.player);
                break;

            case PROTOCOL.ENTER_GAME_ROOM_QUIT:
                this.owner.player.removed();
                break;

            case PROTOCOL.SERVER_CONNECT:
                this.owner.enter_lobby(msg.pop_string());
                break;

            case PROTOCOL.INVITE_FRIEND_REQ:
                invite_friend(msg);
                break;

            case PROTOCOL.INVITE_FRIEND_ACK:
                invite_room();
                break;

            case PROTOCOL.DENY_FRIEND:
                deny_friend(msg);
                break;

            case PROTOCOL.ROOM_REMOVED:
                this.owner.quit_room(this.owner.player.player_index);
                break;

            case PROTOCOL.INVITE_ROOM_QUIT_REQ:
                invite_room_quit();
                break;
            }
        }
Example #2
0
        void IUserState.on_message(FreeNet.CPacket msg)
        {
            PROTOCOL protocol = (PROTOCOL)msg.pop_protocol_id();

            Console.WriteLine("protocol id " + protocol);
            switch (protocol)
            {
            case PROTOCOL.ENTER_GAME_ROOM_REQ:
                Program.game_main.matching_req(this.owner);
                break;
            }
        }
Example #3
0
        public void on_message(CPacket msg)
        {
            // active close를 위한 코딩.
            //   서버에서 종료하라고 연락이 왔는지 체크한다.
            //   만약 종료신호가 맞다면 disconnect를 호출하여 받은쪽에서 먼저 종료 요청을 보낸다.
            switch (msg.protocol_id)
            {
            case SYS_CLOSE_REQ:
                disconnect();
                return;

            case SYS_START_HEARTBEAT:
            {
                // 순서대로 파싱해야 하므로 프로토콜 아이디는 버린다.
                msg.pop_protocol_id();
                // 전송 인터벌.
                byte interval = msg.pop_byte();
                this.heartbeat_sender = new CHeartbeatSender(this, interval);

                if (this.auto_heartbeat)
                {
                    start_heartbeat();
                }
            }
                return;

            case SYS_UPDATE_HEARTBEAT:
                //Console.WriteLine("heartbeat : " + DateTime.Now);
                this.latest_heartbeat_time = DateTime.Now.Ticks;
                return;
            }


            if (this.peer != null)
            {
                try
                {
                    switch (msg.protocol_id)
                    {
                    case SYS_CLOSE_ACK:
                        this.peer.on_removed();
                        break;

                    default:
                        this.peer.on_message(msg);
                        break;
                    }
                }
                catch (Exception)
                {
                    close();
                }
            }

            if (msg.protocol_id == SYS_CLOSE_ACK)
            {
                if (this.on_session_closed != null)
                {
                    this.on_session_closed(this);
                }
            }
        }