Exemplo n.º 1
0
        /// <summary>
        /// 启动服务器(当整个服务器启动起来的时候调用这个初始化)
        /// </summary>
        protected override void Setup()
        {
            System.Diagnostics.Debugger.Launch();

            outboundPeer = new GameServerPeer(this);
            outboundPeer.ConnectTcp(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4520), "LobbyServer");

            RegisterHandlers();
            RegisterS2SHandlers();
            Debug.Initialize(this);
            NHibernateHelper.Initialize();
        }
Exemplo n.º 2
0
        public override void OnOperateRequest(byte[] bytes, GameServerPeer peer, SendParameters sendParameters)
        {
            S2SCreateRoom   roomData    = PackageHelper.Desirialize <S2SCreateRoom>(bytes);
            GameApplication application = GameApplication.Instance as GameApplication;

            if (application == null)
            {
                return;
            }
            Room room = application.CreateRoom(roomData.roomID, roomData.members.Count);

            for (int i = 0; i < roomData.members.Count; ++i)
            {
                S2SRoomMember member = roomData.members[i];
                room.userNames.Add(member.userName);
            }

            OperationResponse response = new OperationResponse((byte)S2SOperationCode.CreateRoom);

            response.ReturnCode = (byte)ReturnCode.Success;
            PackageHelper.SetData(response, bytes);
            peer.SendOperationResponse(response, sendParameters);
        }
Exemplo n.º 3
0
 public abstract void OnOperateRequest(byte[] bytes, GameServerPeer peer, SendParameters sendParameters);