public LiteNetLibFunction ProcessNetFunction(LiteNetLibElementInfo info, NetDataReader reader, bool hookCallback) { if (info.objectId != ObjectId) { return(null); } var elementId = info.elementId; if (elementId >= 0 && elementId < netFunctions.Count) { var netFunction = netFunctions[elementId]; netFunction.DeserializeParameters(reader); if (hookCallback) { netFunction.HookCallback(); } return(netFunction); } else { if (Manager.LogError) { Debug.LogError("[" + name + "] [" + TypeName + "] cannot process net function, functionId [" + info.elementId + "] not found."); } } return(null); }
protected virtual void HandleClientCallFunction(LiteNetLibMessageHandler messageHandler) { var reader = messageHandler.reader; FunctionReceivers receivers = (FunctionReceivers)reader.GetByte(); long connectId = 0; if (receivers == FunctionReceivers.Target) { connectId = reader.GetLong(); } var info = LiteNetLibElementInfo.DeserializeInfo(reader); LiteNetLibIdentity identity; if (Assets.SpawnedObjects.TryGetValue(info.objectId, out identity)) { if (receivers == FunctionReceivers.Server) { identity.ProcessNetFunction(info, reader, true); } else { var netFunction = identity.ProcessNetFunction(info, reader, false); if (receivers == FunctionReceivers.Target) { netFunction.Call(connectId); } else { netFunction.Call(receivers); } } } }
protected virtual void HandleServerCallFunction(LiteNetLibMessageHandler messageHandler) { var reader = messageHandler.reader; var info = LiteNetLibElementInfo.DeserializeInfo(reader); LiteNetLibIdentity identity; if (Assets.SpawnedObjects.TryGetValue(info.objectId, out identity)) { identity.ProcessNetFunction(info, reader, true); } }
public LiteNetLibSyncList ProcessSyncList(LiteNetLibElementInfo info, NetDataReader reader) { if (info.objectId != ObjectId) { return(null); } if (info.behaviourIndex < 0 || info.behaviourIndex >= behaviours.Count) { return(null); } return(behaviours[info.behaviourIndex].ProcessSyncList(info, reader)); }
public LiteNetLibFunction ProcessNetFunction(LiteNetLibElementInfo info, NetDataReader reader, bool hookCallback) { if (info.objectId != ObjectId) { return(null); } if (info.behaviourIndex < 0 || info.behaviourIndex >= behaviours.Count) { return(null); } return(behaviours[info.behaviourIndex].ProcessNetFunction(info, reader, hookCallback)); }
protected virtual void HandleServerUpdateSyncList(LiteNetLibMessageHandler messageHandler) { // List updated at server, if this is host (client and server) then skip it. if (IsServer) { return; } var reader = messageHandler.reader; var info = LiteNetLibElementInfo.DeserializeInfo(reader); LiteNetLibIdentity identity; if (Assets.SpawnedObjects.TryGetValue(info.objectId, out identity)) { identity.ProcessSyncList(info, reader); } }
public LiteNetLibSyncList ProcessSyncList(LiteNetLibElementInfo info, NetDataReader reader) { if (info.objectId != ObjectId) { return(null); } var elementId = info.elementId; if (elementId >= 0 && elementId < syncLists.Count) { var syncList = syncLists[elementId]; syncList.DeserializeOperation(reader); return(syncList); } else { if (Manager.LogError) { Debug.LogError("[" + name + "] [" + TypeName + "] cannot process sync field, fieldId [" + elementId + "] not found."); } } return(null); }
public static void SerializeInfo(LiteNetLibElementInfo info, NetDataWriter writer) { writer.Put(info.objectId); writer.Put(info.behaviourIndex); writer.Put(info.elementId); }
protected void SerializeForSend(NetDataWriter writer) { LiteNetLibElementInfo.SerializeInfo(GetInfo(), writer); SerializeParameters(writer); }