public NetReceivedData(NetConnection connection, NetDataPackage dataPackage) { this.connection = connection; id = dataPackage.id; dataType = dataPackage.dataType != null?Type.GetType(dataPackage.dataType) : null; data = dataPackage.serializedData.Deserialize(); responseRequired = dataPackage.responseRequired; error = (Error)dataPackage.serializedError.Deserialize(); }
public static NetRequest CreateAndSend(NetConnection connection, NetDataPackage dataPackage, int channel = Channel.ReliableSequenced) { NetRequest netRequest = new NetRequest() { id = dataPackage.id, connection = connection, }; dataPackage.responseRequired = true; netRequest.sentDataPackage = dataPackage; netRequest.RegisterResponseHandler(); connection.Send(dataPackage, channel); connection.OnDisconnectEvent.RegisterListener(netRequest.Dispose); return(netRequest); }
public static NetRequest CreateAndSend(NetConnection connection, object serializableData, int channel = Channel.ReliableSequenced) { return(CreateAndSend(connection, NetDataPackage.CreateFrom(serializableData, responseRequired: true), channel)); }