示例#1
0
 public static void SendUDPRoundSync(Room room)
 {
     using (SendGPacket sendGpacket = new SendGPacket())
     {
         sendGpacket.writeH((short)3);
         sendGpacket.writeD(room.UniqueRoomId);
         sendGpacket.writeD(room.mapId * 16 + (int)room.room_type);
         sendGpacket.writeC((byte)room.rodada);
         Game_SyncNet.SendPacket(sendGpacket.mstream.ToArray(),room.UDPServer.Connection);
     }
 }
示例#2
0
        private static void recv(IAsyncResult res)
        {
            if (GameManager.ServerIsClosed)
            {
                return;
            }
            IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 8000);

            byte[] buffer = Game_SyncNet.udp.EndReceive(res, ref remoteEP);
            Thread.Sleep(5);
            new Thread(new ThreadStart(Game_SyncNet.read)).Start();
            if (buffer.Length < 2)
            {
                return;
            }
            Game_SyncNet.LoadPacket(buffer);
        }
示例#3
0
 public static void SendUDPPlayerSync(Room room, SLOT slot,CupomEffects effects,int type)
 {
     using (SendGPacket pk = new SendGPacket())
     {
         pk.writeH((short)1);
         pk.writeD(room.UniqueRoomId);
         pk.writeD(room.mapId * 16 + (int)room.room_type);
         pk.writeQ(room.StartTick);
         pk.writeC((byte)type);
         pk.writeC((byte)room.rodada);
         pk.writeC((byte)slot._id);
         pk.writeC((byte)slot.spawnsCount);
         pk.writeC(BitConverter.GetBytes(slot._playerId)[0]);
         if (type == 0 || type == 2)
         {
             Game_SyncNet.WriteCharaInfo(pk,room,slot,effects);
         }
         Game_SyncNet.SendPacket(pk.mstream.ToArray(),room.UDPServer.Connection);
     }
 }
示例#4
0
        public static void SendCompleteBytes(long playerId,byte[] buffer,int serverId)
        {
            if (buffer.Length == 0)
            {
                return;
            }
            GameServerModel server = Game_SyncNet.GetServer(serverId);

            if (server == null)
            {
                return;
            }
            using (SendGPacket sendGpacket = new SendGPacket())
            {
                sendGpacket.writeH((short)13);
                sendGpacket.writeQ(playerId);
                sendGpacket.writeC((byte)1);
                sendGpacket.writeH((ushort)buffer.Length);
                sendGpacket.writeB(buffer);
                Game_SyncNet.SendPacket(sendGpacket.mstream.ToArray(),server.Connection);
            }
        }
示例#5
0
        public static void SendBytes(long playerId,SendPacket sp,int serverId)
        {
            if (sp == null)
            {
                return;
            }
            GameServerModel server = Game_SyncNet.GetServer(serverId);

            if (server == null)
            {
                return;
            }
            byte[] bytes = sp.GetBytes("Game_SyncNet.SendBytes");
            using (SendGPacket sendGpacket = new SendGPacket())
            {
                sendGpacket.writeH((short)13);
                sendGpacket.writeQ(playerId);
                sendGpacket.writeC((byte)0);
                sendGpacket.writeH((ushort)bytes.Length);
                sendGpacket.writeB(bytes);
                Game_SyncNet.SendPacket(sendGpacket.mstream.ToArray(),server.Connection);
            }
        }
示例#6
0
 public static void UpdateGSCount(int serverId)
 {
     try
     {
         if ((DateTime.Now - Game_SyncNet.LastSyncCount).TotalSeconds < 2.5)
         {
             return;
         }
         Game_SyncNet.LastSyncCount = DateTime.Now;
         int num = 0;
         foreach (Channel channel in ChannelsXML._channels)
         {
             num += channel._players.Count;
         }
         foreach (GameServerModel server in ServersXML._servers)
         {
             if (server._id == serverId)
             {
                 server._LastCount = num;
             }
             else
             {
                 using (SendGPacket sendGpacket = new SendGPacket())
                 {
                     sendGpacket.writeH((short)15);
                     sendGpacket.writeD(serverId);
                     sendGpacket.writeD(num);
                     Game_SyncNet.SendPacket(sendGpacket.mstream.ToArray(),server.Connection);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.warning("[Game_SyncNet.UpdateGSCount] " + ex.ToString());
     }
 }
示例#7
0
 public static GameServerModel GetServer(AccountStatus status)
 {
     return(Game_SyncNet.GetServer((int)status.serverId));
 }