Exemplo n.º 1
0
        protected bool CreateAndWriteRequest <TRequest>(
            NetDataWriter writer,
            ushort requestType,
            TRequest request,
            SerializerDelegate extraRequestSerializer,
            long duration,
            ResponseDelegate responseDelegate)
            where TRequest : INetSerializable
        {
            if (!responseHandlers.ContainsKey(requestType))
            {
                Logging.LogError($"Cannot create request. Request type: {requestType} not registered.");
                return(false);
            }
            if (!responseHandlers[requestType].IsRequestTypeValid(typeof(TRequest)))
            {
                Logging.LogError($"Cannot create request. Request type: {requestType}, {typeof(TRequest)} is not valid message type.");
                return(false);
            }
            // Create request
            uint ackId = CreateRequest(responseHandlers[requestType], duration, responseDelegate);

            // Write request
            writer.Reset();
            writer.PutPackedUShort(RequestMessageType);
            writer.PutPackedUShort(requestType);
            writer.PutPackedUInt(ackId);
            request.Serialize(writer);
            if (extraRequestSerializer != null)
            {
                extraRequestSerializer.Invoke(writer);
            }
            return(true);
        }
Exemplo n.º 2
0
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(netId);
     writer.Put(playerName);
     writer.Put(team);
     writer.PutPackedInt(score);
     writer.PutPackedInt(killCount);
     writer.PutPackedInt(assistCount);
     writer.PutPackedInt(dieCount);
 }
Exemplo n.º 3
0
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(objectId);
     writer.Put(position.x);
     writer.Put(position.y);
     writer.Put(position.z);
     writer.Put(rotation.eulerAngles.x);
     writer.Put(rotation.eulerAngles.y);
     writer.Put(rotation.eulerAngles.z);
 }
Exemplo n.º 4
0
        public void Serialize(NetDataWriter writer)
        {
            if (!IsServer)
            {
                return;
            }

            writer.PutPackedUInt(Identity.ObjectId);
            writer.Put(BehaviourIndex);
            OnSerialize(writer);
        }
 private void ClientSendTransformWriter(NetDataWriter writer, TransformResult transformResult)
 {
     writer.PutPackedUInt(ObjectId);
     writer.Put(BehaviourIndex);
     SerializePositionAxis(writer, transformResult.position.x, syncPositionX);
     SerializePositionAxis(writer, transformResult.position.y, syncPositionY);
     SerializePositionAxis(writer, transformResult.position.z, syncPositionZ);
     SerializeRotationAxis(writer, transformResult.rotation.eulerAngles.x, syncRotationX);
     SerializeRotationAxis(writer, transformResult.rotation.eulerAngles.y, syncRotationY);
     SerializeRotationAxis(writer, transformResult.rotation.eulerAngles.z, syncRotationZ);
     writer.Put(GetTimeStamp());
 }
 private void RequestProceeded(long connectionId, uint requestId, AckResponseCode responseCode, INetSerializable response, SerializerDelegate responseSerializer)
 {
     // Write response
     Writer.Reset();
     Writer.PutPackedUShort(ResponseMessageType);
     Writer.PutPackedUInt(requestId);
     Writer.PutValue(responseCode);
     Writer.Put(response);
     if (responseSerializer != null)
     {
         responseSerializer.Invoke(Writer);
     }
     // Send response
     SendMessage(connectionId, 0, DeliveryMethod.ReliableUnordered, Writer);
 }
Exemplo n.º 7
0
 public void Serialize(NetDataWriter writer)
 {
     writer.Put((byte)type);
     if (type != SummonType.None)
     {
         writer.Put(dataId);
         switch (type)
         {
         case SummonType.Skill:
             writer.Put(summonRemainsDuration);
             break;
         }
         writer.PutPackedUInt(objectId);
     }
 }
        protected bool CreateAndWriteRequest <TRequest>(
            NetDataWriter writer,
            ushort requestType,
            TRequest request,
            ResponseDelegate <INetSerializable> responseDelegate,
            int millisecondsTimeout,
            SerializerDelegate extraRequestSerializer)
            where TRequest : INetSerializable, new()
        {
            if (!responseHandlers.ContainsKey(requestType))
            {
                responseDelegate.Invoke(new ResponseHandlerData(nextRequestId++, this, -1, null), AckResponseCode.Unimplemented, EmptyMessage.Value);
                Logging.LogError($"Cannot create request. Request type: {requestType} not registered.");
                return(false);
            }
            if (!responseHandlers[requestType].IsRequestTypeValid(typeof(TRequest)))
            {
                responseDelegate.Invoke(new ResponseHandlerData(nextRequestId++, this, -1, null), AckResponseCode.Unimplemented, EmptyMessage.Value);
                Logging.LogError($"Cannot create request. Request type: {requestType}, {typeof(TRequest)} is not valid message type.");
                return(false);
            }
            // Create request
            uint requestId = CreateRequest(responseHandlers[requestType], responseDelegate, millisecondsTimeout);

            // Write request
            writer.Reset();
            writer.PutPackedUShort(RequestMessageType);
            writer.PutPackedUShort(requestType);
            writer.PutPackedUInt(requestId);
            writer.Put(request);
            if (extraRequestSerializer != null)
            {
                extraRequestSerializer.Invoke(writer);
            }
            return(true);
        }
Exemplo n.º 9
0
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(objectId);
     writer.PutPackedLong(connectionId);
 }
Exemplo n.º 10
0
 public static void SerializeInfo(LiteNetLibElementInfo info, NetDataWriter writer)
 {
     writer.PutPackedUInt(info.objectId);
     writer.PutPackedUInt((uint)info.elementId);
 }
Exemplo n.º 11
0
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(value);
 }
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(objectId);
     writer.Put(reasons);
 }
 public void Serialize(NetDataWriter writer)
 {
     writer.PutPackedUInt(packetVersion);
 }