Esempio n. 1
0
        public LobbyServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub  = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            // --- 클라에게 받는 패킷 ---

            // 채팅 메세지 처리
            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return(true);
            };

            // 방 만들기 : 룸 서버로 이동하기
            stub.request_make_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string name) =>
            {
                int server_type = (int)CasualCommon.Server.Room;

                // 아무 서버나 하나 고른다
                ZNet.MasterInfo svr;
                if (m_Core.SelectServer(server_type, out svr))
                {
                    // 이동 파라미터 구성
                    ZNet.ArrByte param_buffer;
                    CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                    param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToRoom, CasualCommonSvr.MoveParam.ParamRoom.RoomMake, Guid.NewGuid(), this.svrRemoteID);
                    CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                    m_Core.ServerMoveStart(remote, svr.m_Addr, param_buffer, param.room_id);
                }
                return(true);
            };

            // 방 입장하기 : 룸서버 이동
            stub.request_join_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID) =>
            {
                int server_type = (int)CasualCommon.Server.Room;

                ZNet.MasterInfo[] svr_array;
                m_Core.GetServerList(server_type, out svr_array);

                ZNet.MasterInfo find_server = null;
                if (roomID == Guid.Empty)
                {
                    // 방 검색
                    foreach (var one_room in RemoteRooms)
                    {
                        // 인원숫자 검사 : 입장 가능한 방
                        if (one_room.Value.users.Count < one_room.Value.max_users)
                        {
                            // 서버 검색
                            foreach (var obj in svr_array)
                            {
                                // 해당 방이 존재하는지 확인
                                if ((ZNet.RemoteID)one_room.Value.remote_svr == obj.m_remote)
                                {
                                    roomID      = one_room.Value.roomID;
                                    find_server = obj;
                                    break;
                                }
                            }
                        }
                        if (find_server != null)
                        {
                            break;
                        }
                    }

                    if (find_server == null)
                    {
                        // 해당 서버 없음 : 이동 실패
                        return(true);
                    }


                    // 이동 파라미터 구성
                    ZNet.ArrByte param_buffer;
                    CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                    param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToRoom, CasualCommonSvr.MoveParam.ParamRoom.RoomJoin, roomID, this.svrRemoteID);
                    CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                    m_Core.ServerMoveStart(remote, find_server.m_Addr, param_buffer, roomID);
                }
                else
                {
                    // 지정된 roomID가 존재하는 룸서버를 골라서 해당 방으로 입장시켜준다
                }
                return(true);
            };



            // --- 서버간 통신 패킷 ---

            // 방생성 + 입장
            stub.room_lobby_makeroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, string name, int number, ZNet.RemoteID remote_svr, ZNet.RemoteID remote_lobby, Guid userID) =>
            {
                CasualCommonSvr.CRoom new_room = new CasualCommonSvr.CRoom();
                new_room.From(roomID, name, number, (int)remote_svr, (int)remote_lobby);
                new_room.users.Add(userID);
                RemoteRooms.Add(roomID, new_room);
                return(true);
            };

            // 방입장
            stub.room_lobby_joinroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, Guid userID) =>
            {
                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(roomID, out room_join))
                {
                    room_join.users.Add(userID);
                }
                return(true);
            };

            // 방퇴장
            stub.room_lobby_outroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, Guid userID) =>
            {
                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(roomID, out room_join))
                {
                    room_join.users.Remove(userID);
                }

                if (room_join.users.Count == 0)
                {
                    RemoteRooms.Remove(roomID);
                }
                return(true);
            };



            // -- Core Event --

            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    CasualCommonSvr.MoveParam param;
                    CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장은 허용하지 않음
                    m_Core.CloseRemoteClient(remote);
                }

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                RemoteClients.Remove(remote);
                Console.WriteLine("Client {0} Leave. MoveServer{1}  Current={2}\n", remote, bMoveServer, RemoteClients.Count);
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "로비서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            // 파라미터 검사후 서버이동 승인 여부 결정하기
            m_Core.move_server_param_handler = (ZNet.ArrByte move_param, int count_idx) =>
            {
                CasualCommonSvr.MoveParam param;
                CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                Console.WriteLine("MoveParam_2 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);

                // 이서버가 로비서버이므로 파라미터가 로비서버일때만 승인해준다
                if (param.moveTo == CasualCommonSvr.MoveParam.ParamMove.MoveToLobby)
                {
                    return(true);
                }

                return(false);
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_hanlder = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));
            };
            m_Core.server_leave_hanlder = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));
            };

            m_Core.server_master_join_hanlder = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                this.svrRemoteID = (int)myRemoteID;
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_hanlder = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_hanlder = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));
            };
        }
Esempio n. 2
0
        public LoginServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub  = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return(true);
            };

            stub.request_lobby_list = (ZNet.RemoteID remote, ZNet.CPackOption pkOption) =>
            {
                proxy.notify_lobby_list(remote, ZNet.CPackOption.Basic, this.lobby_list);
                return(true);
            };



            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장
                    CasualCommonSvr.CUser rc = new CasualCommonSvr.CUser();
                    rc.data.userID = Guid.NewGuid();
                    rc.data.info   = string.Format("유저_{0}", remote);
                    rc.data.temp   = "일반입장";
                    RemoteClients.Add(remote, rc);
                }

                proxy.notify_lobby_list(remote, ZNet.CPackOption.Basic, this.lobby_list); // 입장시 로비 리스트 보냄

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                RemoteClients.Remove(remote);
                Console.WriteLine("Client {0} Leave. MoveServer{1}  Current={2}\n", remote, bMoveServer, RemoteClients.Count);
            };

            // 해당 서버 타입의 조건을 검사한후 응답처리
            stub.request_go_lobby = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string lobbyname) =>
            {
                // 실제 해당 서버의 검증 작업
                ZNet.MasterInfo[] svr_array;
                m_Core.GetServerList((int)CasualCommon.Server.Lobby, out svr_array);

                foreach (var obj in svr_array)
                {
                    // 지정한 로비 서버 이름 확인
                    if (lobbyname == obj.m_Description)
                    {
                        // 이동 파라미터 구성
                        ZNet.ArrByte param_buffer;
                        CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                        param.moveTo = CasualCommonSvr.MoveParam.ParamMove.MoveToLobby;
                        CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                        // 여기서 내부패킷으로 자동적으로 서버이동이 처리 된다
                        m_Core.ServerMoveStart(remote, obj.m_Addr, param_buffer, new Guid());

                        Console.WriteLine("MoveParam_1 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);
                        return(true);
                    }
                }
                return(true);
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "로그인서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_hanlder = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));

                // 입장한 시점 : 이 서버의 세부 정보는 이후 refresh_handler를 통해 들어오면 처리해야한다
            };
            m_Core.server_leave_hanlder = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));

                // 퇴장한 서버에 대한 처리
                lobby_list.Remove(remote);
            };

            m_Core.server_master_join_hanlder = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_hanlder = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_hanlder = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));

                // 로비 리스트 정보 갱신
                lobby_list.Remove(master_info.m_remote);
                if ((CasualCommon.Server)master_info.m_ServerType == CasualCommon.Server.Lobby)
                {
                    lobby_list.Add(master_info.m_remote, master_info);
                }
            };
        }
Esempio n. 3
0
        public RoomServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub  = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            // --- 클라에게 받는 패킷 ---

            // 채팅 메세지 처리
            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return(true);
            };

            // 방 나가기
            stub.request_out_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption) =>
            {
                int server_type = (int)CasualCommon.Server.Lobby;

                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    return(true);
                }

                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(rc.roomID, out room_join))
                {
                    ZNet.MasterInfo[] svr_array;
                    m_Core.GetServerList(server_type, out svr_array);

                    // 서버 검색
                    foreach (var obj in svr_array)
                    {
                        // 원래 방입장하기 전에 있었던 로비서버로 돌아가기 위해
                        if (obj.m_remote == (ZNet.RemoteID)room_join.remote_lobby)
                        {
                            // 이동 파라미터 구성 : 타겟을 로비서버로 (나머지 파라미터는 룸->로비 이동시에는 별 의미없음)
                            ZNet.ArrByte param_buffer;
                            CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                            param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToLobby, CasualCommonSvr.MoveParam.ParamRoom.RoomNull, Guid.NewGuid(), this.svrRemoteID);
                            CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                            m_Core.ServerMoveStart(remote, obj.m_Addr, param_buffer, param.room_id);
                            return(true);
                        }
                    }
                }
                return(true);
            };



            // 파라미터 검사후 서버이동 승인 여부 결정하기
            m_Core.move_server_param_handler = (ZNet.ArrByte move_param, int count_idx) =>
            {
                CasualCommonSvr.MoveParam param;
                CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                Console.WriteLine("MoveParam_2 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);

                if (param.moveTo == CasualCommonSvr.MoveParam.ParamMove.MoveToRoom)
                {
                    if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomMake)
                    {
                        return(true);
                    }
                    else if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomJoin)
                    {
                        // 현재 이 방의 인원숫자 + allow숫자(count_idx)를 비교하여 입장 허용 여부를 결정한다
                        CasualCommonSvr.CRoom room_join;
                        if (RemoteRooms.TryGetValue(param.room_id, out room_join))
                        {
                            //if (room_join.users.Count + count_idx < 1)
                            if (room_join.users.Count + count_idx < room_join.max_users)
                            {
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            };

            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    CasualCommonSvr.MoveParam param;
                    CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                    if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomMake)
                    {
                        // 방생성
                        CasualCommonSvr.CRoom new_room = new CasualCommonSvr.CRoom();
                        new_room.From(param.room_id, "방이름", 123, this.svrRemoteID, param.lobby_remote);

                        if (RemoteRooms.ContainsKey(param.room_id))
                        {
                            // 동일한 guid생성을 허용금지 : 예외처리필요
                        }

                        RemoteRooms.Add(param.room_id, new_room);

                        new_room.users.Add(rc.data.userID);

                        // 로비서버에게 방생성을 알린다
                        proxy.room_lobby_makeroom((ZNet.RemoteID)new_room.remote_lobby, ZNet.CPackOption.Basic,
                                                  new_room.roomID, new_room.name, new_room.number, (ZNet.RemoteID)new_room.remote_svr, (ZNet.RemoteID)new_room.remote_lobby, rc.data.userID);
                    }
                    else if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomJoin)
                    {
                        // 방입장
                        CasualCommonSvr.CRoom room_join;
                        if (RemoteRooms.TryGetValue(param.room_id, out room_join))
                        {
                            room_join.users.Add(rc.data.userID);
                        }
                        else
                        {
                            Console.WriteLine("move server join error!!! {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                            m_Core.CloseRemoteClient(remote);
                            return;
                        }

                        // 로비서버에게 방입장을 알린다
                        proxy.room_lobby_joinroom((ZNet.RemoteID)room_join.remote_lobby, ZNet.CPackOption.Basic, room_join.roomID, rc.data.userID);
                    }

                    rc.roomID = param.room_id;

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장은 허용하지 않음
                    m_Core.CloseRemoteClient(remote);
                }

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc))
                {
                    CasualCommonSvr.CRoom room_join;
                    if (RemoteRooms.TryGetValue(rc.roomID, out room_join))
                    {
                        room_join.users.Remove(rc.data.userID);
                    }

                    if (room_join.users.Count == 0)
                    {
                        RemoteRooms.Remove(rc.roomID);
                    }

                    // 로비서버에게 방퇴장을 알린다
                    proxy.room_lobby_outroom((ZNet.RemoteID)room_join.remote_lobby, ZNet.CPackOption.Basic, room_join.roomID, rc.data.userID);

                    Console.WriteLine("Client {0} Leave.\n", remote);
                }
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "룸서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));
            };
            m_Core.server_leave_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));
            };

            m_Core.server_master_join_handler = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                this.svrRemoteID = (int)myRemoteID;
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_handler = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_handler = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));
            };
        }
Esempio n. 4
0
        public LobbyServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            // --- 클라에게 받는 패킷 ---

            // 채팅 메세지 처리
            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return true;
            };

            // 방 만들기 : 룸 서버로 이동하기
            stub.request_make_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string name) =>
            {
                int server_type = (int)CasualCommon.Server.Room;

                // 아무 서버나 하나 고른다
                ZNet.MasterInfo svr;
                if (m_Core.SelectServer(server_type, out svr))
                {
                    // 이동 파라미터 구성
                    ZNet.ArrByte param_buffer;
                    CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                    param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToRoom, CasualCommonSvr.MoveParam.ParamRoom.RoomMake, Guid.NewGuid(), this.svrRemoteID);
                    CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                    m_Core.ServerMoveStart(remote, svr.m_Addr, param_buffer, param.room_id);
                }
                return true;
            };

            // 방 입장하기 : 룸서버 이동
            stub.request_join_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID) =>
            {
                int server_type = (int)CasualCommon.Server.Room;

                ZNet.MasterInfo[] svr_array;
                m_Core.GetServerList(server_type, out svr_array);

                ZNet.MasterInfo find_server = null;
                if (roomID == Guid.Empty)
                {
                    // 방 검색
                    foreach (var one_room in RemoteRooms)
                    {
                        // 인원숫자 검사 : 입장 가능한 방
                        if (one_room.Value.users.Count < one_room.Value.max_users)
                        {
                            // 서버 검색
                            foreach (var obj in svr_array)
                            {
                                // 해당 방이 존재하는지 확인
                                if ((ZNet.RemoteID)one_room.Value.remote_svr == obj.m_remote)
                                {
                                    roomID = one_room.Value.roomID;
                                    find_server = obj;
                                    break;
                                }
                            }
                        }
                        if (find_server != null)
                            break;
                    }

                    if (find_server == null)
                    {
                        // 해당 서버 없음 : 이동 실패
                        return true;
                    }


                    // 이동 파라미터 구성
                    ZNet.ArrByte param_buffer;
                    CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                    param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToRoom, CasualCommonSvr.MoveParam.ParamRoom.RoomJoin, roomID, this.svrRemoteID);
                    CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                    m_Core.ServerMoveStart(remote, find_server.m_Addr, param_buffer, roomID);
                }
                else
                {
                    // 지정된 roomID가 존재하는 룸서버를 골라서 해당 방으로 입장시켜준다
                }
                return true;
            };




            // --- 서버간 통신 패킷 ---

            // 방생성 + 입장
            stub.room_lobby_makeroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, string name, int number, ZNet.RemoteID remote_svr, ZNet.RemoteID remote_lobby, Guid userID) =>
            {
                CasualCommonSvr.CRoom new_room = new CasualCommonSvr.CRoom();
                new_room.From(roomID, name, number, (int)remote_svr, (int)remote_lobby);
                new_room.users.Add(userID);
                RemoteRooms.Add(roomID, new_room);
                return true;
            };

            // 방입장
            stub.room_lobby_joinroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, Guid userID) =>
            {
                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(roomID, out room_join))
                {
                    room_join.users.Add(userID);
                }
                return true;
            };

            // 방퇴장
            stub.room_lobby_outroom = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, Guid userID) =>
            {
                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(roomID, out room_join))
                {
                    room_join.users.Remove(userID);
                }

                if (room_join.users.Count == 0)
                {
                    RemoteRooms.Remove(roomID);
                }
                return true;
            };




            // -- Core Event --

            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    CasualCommonSvr.MoveParam param;
                    CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장은 허용하지 않음
                    m_Core.CloseRemoteClient(remote);
                }

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                RemoteClients.Remove(remote);
                Console.WriteLine("Client {0} Leave. MoveServer{1}  Current={2}\n", remote, bMoveServer, RemoteClients.Count);
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "로비서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            // 파라미터 검사후 서버이동 승인 여부 결정하기
            m_Core.move_server_param_handler = (ZNet.ArrByte move_param, int count_idx) =>
            {
                CasualCommonSvr.MoveParam param;
                CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                Console.WriteLine("MoveParam_2 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);

                // 이서버가 로비서버이므로 파라미터가 로비서버일때만 승인해준다
                if (param.moveTo == CasualCommonSvr.MoveParam.ParamMove.MoveToLobby)
                    return true;

                return false;
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));
            };
            m_Core.server_leave_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));
            };

            m_Core.server_master_join_handler = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                this.svrRemoteID = (int)myRemoteID;
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_handler = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_handler = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));
            };
        }
Esempio n. 5
0
        public LoginServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return true;
            };

            stub.request_lobby_list = (ZNet.RemoteID remote, ZNet.CPackOption pkOption) =>
            {
                proxy.notify_lobby_list(remote, ZNet.CPackOption.Basic, this.lobby_list);
                return true;
            };




            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장
                    CasualCommonSvr.CUser rc = new CasualCommonSvr.CUser();
                    rc.data.userID = Guid.NewGuid();
                    rc.data.info = string.Format("유저_{0}", remote);
                    rc.data.temp = "일반입장";
                    RemoteClients.Add(remote, rc);
                }

                proxy.notify_lobby_list(remote, ZNet.CPackOption.Basic, this.lobby_list); // 입장시 로비 리스트 보냄

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                RemoteClients.Remove(remote);
                Console.WriteLine("Client {0} Leave. MoveServer{1}  Current={2}\n", remote, bMoveServer, RemoteClients.Count);
            };

            // 해당 서버 타입의 조건을 검사한후 응답처리
            stub.request_go_lobby = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string lobbyname) =>
            {
                // 실제 해당 서버의 검증 작업
                ZNet.MasterInfo[] svr_array;
                m_Core.GetServerList((int)CasualCommon.Server.Lobby, out svr_array);

                foreach (var obj in svr_array)
                {
                    // 지정한 로비 서버 이름 확인
                    if(lobbyname == obj.m_Description)
                    {
                        // 이동 파라미터 구성
                        ZNet.ArrByte param_buffer;
                        CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                        param.moveTo = CasualCommonSvr.MoveParam.ParamMove.MoveToLobby;
                        CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                        // 여기서 내부패킷으로 자동적으로 서버이동이 처리 된다
                        m_Core.ServerMoveStart(remote, obj.m_Addr, param_buffer, new Guid());

                        Console.WriteLine("MoveParam_1 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);
                        return true;
                    }
                }
                return true;
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "로그인서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));

                // 입장한 시점 : 이 서버의 세부 정보는 이후 refresh_handler를 통해 들어오면 처리해야한다
            };
            m_Core.server_leave_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));

                // 퇴장한 서버에 대한 처리
                lobby_list.Remove(remote);
            };

            m_Core.server_master_join_handler = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_handler = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_handler = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));

                // 로비 리스트 정보 갱신
                lobby_list.Remove(master_info.m_remote);
                if ((CasualCommon.Server)master_info.m_ServerType == CasualCommon.Server.Lobby)
                {
                    lobby_list.Add(master_info.m_remote, master_info);
                }
            };
        }
Esempio n. 6
0
        public RoomServer()
        {
            m_Core = new ZNet.CoreServerNet();

            proxy = new Rmi.Proxy();
            stub = new Rmi.Stub();

            m_Core.Attach(proxy, stub);



            // --- 클라에게 받는 패킷 ---

            // 채팅 메세지 처리
            stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg) =>
            {
                Console.WriteLine("Remote[{0}] msg : {1}", remote, msg);
                proxy.Chat(remote, ZNet.CPackOption.Basic, msg);
                return true;
            };

            // 방 나가기
            stub.request_out_room = (ZNet.RemoteID remote, ZNet.CPackOption pkOption) =>
            {
                int server_type = (int)CasualCommon.Server.Lobby;

                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                    return true;

                CasualCommonSvr.CRoom room_join;
                if (RemoteRooms.TryGetValue(rc.roomID, out room_join))
                {
                    ZNet.MasterInfo[] svr_array;
                    m_Core.GetServerList(server_type, out svr_array);

                    // 서버 검색
                    foreach (var obj in svr_array)
                    {
                        // 원래 방입장하기 전에 있었던 로비서버로 돌아가기 위해
                        if (obj.m_remote == (ZNet.RemoteID)room_join.remote_lobby)
                        {
                            // 이동 파라미터 구성 : 타겟을 로비서버로 (나머지 파라미터는 룸->로비 이동시에는 별 의미없음)
                            ZNet.ArrByte param_buffer;
                            CasualCommonSvr.MoveParam param = new CasualCommonSvr.MoveParam();
                            param.From(CasualCommonSvr.MoveParam.ParamMove.MoveToLobby, CasualCommonSvr.MoveParam.ParamRoom.RoomNull, Guid.NewGuid(), this.svrRemoteID);
                            CasualCommonSvr.Common.ServerMoveParam1(param, out param_buffer);

                            m_Core.ServerMoveStart(remote, obj.m_Addr, param_buffer, param.room_id);
                            return true;
                        }
                    }
                }
                return true;
            };




            // 파라미터 검사후 서버이동 승인 여부 결정하기
            m_Core.move_server_param_handler = (ZNet.ArrByte move_param, int count_idx) =>
            {
                CasualCommonSvr.MoveParam param;
                CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                Console.WriteLine("MoveParam_2 {0} {1} {2}", param.moveTo, param.roomJoin, param.room_id);

                if (param.moveTo == CasualCommonSvr.MoveParam.ParamMove.MoveToRoom)
                {
                    if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomMake)
                    {
                        return true;
                    }
                    else if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomJoin)
                    {
                        // 현재 이 방의 인원숫자 + allow숫자(count_idx)를 비교하여 입장 허용 여부를 결정한다
                        CasualCommonSvr.CRoom room_join;
                        if (RemoteRooms.TryGetValue(param.room_id, out room_join))
                        {
                            //if (room_join.users.Count + count_idx < 1)
                            if (room_join.users.Count + count_idx < room_join.max_users)
                                return true;
                        }
                    }
                }
                return false;
            };

            m_Core.client_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr, ZNet.ArrByte move_server, ZNet.ArrByte move_param) =>
            {
                // 서버이동으로 입장한 경우
                if (move_server.Count > 0)
                {
                    CasualCommonSvr.CUser rc;
                    CasualCommonSvr.Common.ServerMoveComplete(move_server, out rc);

                    CasualCommonSvr.MoveParam param;
                    CasualCommonSvr.Common.ServerMoveParam2(move_param, out param);

                    if (param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomMake)
                    {
                        // 방생성
                        CasualCommonSvr.CRoom new_room = new CasualCommonSvr.CRoom();
                        new_room.From(param.room_id, "방이름", 123, this.svrRemoteID, param.lobby_remote);

                        if (RemoteRooms.ContainsKey(param.room_id))
                        {
                            // 동일한 guid생성을 허용금지 : 예외처리필요
                        }

                        RemoteRooms.Add(param.room_id, new_room);

                        new_room.users.Add(rc.data.userID);

                        // 로비서버에게 방생성을 알린다
                        proxy.room_lobby_makeroom((ZNet.RemoteID)new_room.remote_lobby, ZNet.CPackOption.Basic,
                            new_room.roomID, new_room.name, new_room.number, (ZNet.RemoteID)new_room.remote_svr, (ZNet.RemoteID)new_room.remote_lobby, rc.data.userID);
                    }
                    else if(param.roomJoin == CasualCommonSvr.MoveParam.ParamRoom.RoomJoin)
                    {
                        // 방입장
                        CasualCommonSvr.CRoom room_join;
                        if (RemoteRooms.TryGetValue(param.room_id, out room_join))
                        {
                            room_join.users.Add(rc.data.userID);
                        }
                        else
                        {
                            Console.WriteLine("move server join error!!! {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                            m_Core.CloseRemoteClient(remote);
                            return;
                        }

                        // 로비서버에게 방입장을 알린다
                        proxy.room_lobby_joinroom((ZNet.RemoteID)room_join.remote_lobby, ZNet.CPackOption.Basic, room_join.roomID, rc.data.userID);
                    }

                    rc.roomID = param.room_id;

                    Console.WriteLine("move server complete  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
                    RemoteClients.Add(remote, rc);
                }
                else
                {
                    // 일반 입장은 허용하지 않음
                    m_Core.CloseRemoteClient(remote);
                }

                Console.WriteLine("Client {0} is Join {1}:{2}. Current={3}\n", remote, addr.m_ip, addr.m_port, RemoteClients.Count);
            };
            m_Core.client_leave_handler = (ZNet.RemoteID remote, bool bMoveServer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc))
                {
                    CasualCommonSvr.CRoom room_join;
                    if (RemoteRooms.TryGetValue(rc.roomID, out room_join))
                    {
                        room_join.users.Remove(rc.data.userID);
                    }

                    if (room_join.users.Count == 0)
                    {
                        RemoteRooms.Remove(rc.roomID);
                    }

                    // 로비서버에게 방퇴장을 알린다
                    proxy.room_lobby_outroom((ZNet.RemoteID)room_join.remote_lobby, ZNet.CPackOption.Basic, room_join.roomID, rc.data.userID);

                    Console.WriteLine("Client {0} Leave.\n", remote);
                }
            };

            m_Core.move_server_start_handler = (ZNet.RemoteID remote, out ZNet.ArrByte buffer) =>
            {
                CasualCommonSvr.CUser rc;
                if (RemoteClients.TryGetValue(remote, out rc) == false)
                {
                    buffer = null;
                    return;
                }
                rc.data.temp = "룸서버";

                // 여기서는 이동할 서버로 동기화 시킬 유저 데이터를 구성하여 buffer에 넣어둔다 -> 완료서버에서 해당 데이터를 그대로 받게된다
                CasualCommonSvr.Common.ServerMoveStart(rc, out buffer);

                Console.WriteLine("move server start  {0} {1} {2}", rc.data.userID, rc.data.info, rc.data.temp);
            };

            m_Core.message_handler = (ZNet.ResultInfo result) =>
            {
                string str_msg = "Msg : ";
                str_msg += result.msg;
                Console.WriteLine(str_msg);
            };
            m_Core.exception_handler = (Exception e) =>
            {
                string str_msg = "Exception : ";
                str_msg += e.ToString();
                Console.WriteLine(str_msg);
            };

            m_Core.server_join_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 입장 remoteID {0}", remote));
            };
            m_Core.server_leave_handler = (ZNet.RemoteID remote, ZNet.NetAddress addr) =>
            {
                //Console.WriteLine(string.Format("서버P2P맴버 퇴장 remoteID {0}", remote));
            };

            m_Core.server_master_join_handler = (ZNet.RemoteID remote, ZNet.RemoteID myRemoteID) =>
            {
                this.svrRemoteID = (int)myRemoteID;
                Console.WriteLine(string.Format("마스터서버에 입장성공 remoteID {0}", myRemoteID));
            };
            m_Core.server_master_leave_handler = () =>
            {
                Console.WriteLine(string.Format("마스터서버와 연결종료!!!"));
                run_program = false;    // 자동 종료처리를 위해
            };

            m_Core.server_refresh_handler = (ZNet.MasterInfo master_info) =>
            {
                //Console.WriteLine(string.Format("서버P2P remote:{0} type:{1}[{2}] current:{3} addr:{4}:{5}",
                //    master_info.m_remote,
                //    (CasualCommon.Server)master_info.m_ServerType,
                //    master_info.m_Description,
                //    master_info.m_Clients,
                //    master_info.m_Addr.m_ip,
                //    master_info.m_Addr.m_port
                //    ));
            };
        }