GetPacketId() 공개 추상적인 메소드

public abstract GetPacketId ( ) : int
리턴 int
예제 #1
0
 private static void RegisterProto(Type type)
 {
     System.Object target = Activator.CreateInstance(type);
     if (target is Packet)
     {
         Packet packet = target as Packet;
         _factory[packet.GetPacketId()] = new PacketFactory(type);
         ReturnPacket(packet);
     }
     else
     {
         LogHelper.PrintError($"[ProtoHelper]RegisterProto:{type.ToString()} error.");
     }
 }
예제 #2
0
 private static void RegisterProto(Type type)
 {
     System.Object target = Activator.CreateInstance(type);
     if (target is Packet)
     {
         Packet packet = target as Packet;
         _factory[packet.GetPacketId()] = new PacketFactory(type);
         ReturnPacket(packet);
     }
     else
     {
         LogUtil.LogUtility.PrintError(string.Format("[ProtoRegister]Register {0} error!", type.ToString()));
     }
 }
예제 #3
0
 public static void ReturnPacket(Packet packet)
 {
     lock (_thisLock)
     {
         int type = packet.GetPacketId();
         if (_factory.ContainsKey(type))
         {
             _factory[type].ReturnPacket(packet);
         }
         else
         {
             LogHelper.PrintError($"[ProtoHelper]ReturnPacket:{type.ToString()}!");
         }
     }
 }
예제 #4
0
 public static void ReturnPacket(Packet packet)
 {
     lock (thisLock)
     {
         int type = packet.GetPacketId();
         if (_factory.ContainsKey(type))
         {
             _factory[type].ReturnPacket(packet);
         }
         else
         {
             LogHelper.PrintError(string.Format("[ProtoRegister]UnRegister {0}!", type.ToString()));
         }
     }
 }
예제 #5
0
 public static void ReturnPacket(Packet packet)
 {
     lock (_lock)
     {
         int packetId = packet.GetPacketId();
         if (_factoryDict.ContainsKey(packetId))
         {
             _factoryDict[packetId].ReturnPacket(packet);
         }
         else
         {
             LogHelper.PrintError($"[ProtoHelper]ReturnPacket:{packetId.ToString()} error.");
         }
     }
 }
예제 #6
0
    //패킷의 헤더 생성
    byte[] CreateHeader <T>(Packet <T> data)
    {
        byte[] msg = data.GetPacketData();

        HeaderData       headerData       = new HeaderData();
        HeaderSerializer headerSerializer = new HeaderSerializer();

        headerData.length = (short)msg.Length;
        headerData.source = (byte)NetworkManager.Source.ClientSource;
        headerData.id     = (byte)data.GetPacketId();

        headerSerializer.Serialize(headerData);
        byte[] header = headerSerializer.GetSerializedData();

        return(header);
    }