public unsafe void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var entities = chunk.GetNativeArray(entityType); var rpcInBuffer = chunk.GetBufferAccessor(inBufferType); var rpcOutBuffer = chunk.GetBufferAccessor(outBufferType); var connections = chunk.GetNativeArray(connectionType); var deserializeState = new RpcDeserializerState { ghostMap = ghostMap }; for (int i = 0; i < rpcInBuffer.Length; ++i) { if (driver.GetConnectionState(connections[i].Value) != NetworkConnection.State.Connected) { continue; } var dynArray = rpcInBuffer[i]; var parameters = new RpcExecutor.Parameters { Reader = dynArray.AsDataStreamReader(), CommandBuffer = commandBuffer, State = (IntPtr)UnsafeUtility.AddressOf(ref deserializeState), Connection = entities[i], JobIndex = chunkIndex }; int msgHeaderLen = dynamicAssemblyList ? 10 : 4; while (parameters.Reader.GetBytesRead() < parameters.Reader.Length) { int rpcIndex = 0; if (dynamicAssemblyList) { ulong rpcHash = parameters.Reader.ReadULong(); if (rpcHash == 0) { rpcIndex = ushort.MaxValue; protocolVersion.RpcCollectionVersion = 0; protocolVersion.ComponentCollectionVersion = 0; } else if (rpcHash != 0 && !hashToIndex.TryGetValue(rpcHash, out rpcIndex)) { errors.Enqueue(new RpcReceiveError { connection = entities[i], error = ErrorCodes.InvalidRpc }); break; } } else { rpcIndex = parameters.Reader.ReadUShort(); } var rpcSize = parameters.Reader.ReadUShort(); if (rpcIndex == ushort.MaxValue) { // Special value for NetworkProtocolVersion var netCodeVersion = parameters.Reader.ReadInt(); var gameVersion = parameters.Reader.ReadInt(); var rpcVersion = parameters.Reader.ReadULong(); var componentVersion = parameters.Reader.ReadULong(); if (netCodeVersion != protocolVersion.NetCodeVersion || gameVersion != protocolVersion.GameVersion || rpcVersion != protocolVersion.RpcCollectionVersion || componentVersion != protocolVersion.ComponentCollectionVersion) { errors.Enqueue(new RpcReceiveError { connection = entities[i], error = ErrorCodes.ProtocolMismatch }); break; } //The connection has received the version. RpcSystem can't accept any rpc's if the NetworkProtocolVersion //has not been received first. var connection = connections[i]; connection.ProtocolVersionReceived = 1; connections[i] = connection; } else if (rpcIndex >= execute.Length) { //If this is the server, we must disconnect the connection errors.Enqueue(new RpcReceiveError { connection = entities[i], error = ErrorCodes.InvalidRpc }); break; } else if (connections[i].ProtocolVersionReceived == 0) { errors.Enqueue(new RpcReceiveError { connection = entities[i], error = ErrorCodes.VersionNotReceived }); break; } else { execute[rpcIndex].Execute.Ptr.Invoke(ref parameters); } } dynArray.Clear(); var sendBuffer = rpcOutBuffer[i]; while (sendBuffer.Length > 0) { DataStreamWriter tmp = driver.BeginSend(reliablePipeline, connections[i].Value); // If sending failed we stop and wait until next frame if (!tmp.IsCreated) { break; } if (sendBuffer.Length > tmp.Capacity) { var sendArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <byte>(sendBuffer.GetUnsafePtr(), sendBuffer.Length, Allocator.Invalid); #if ENABLE_UNITY_COLLECTIONS_CHECKS var safety = NativeArrayUnsafeUtility.GetAtomicSafetyHandle(sendBuffer.AsNativeArray()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref sendArray, safety); #endif var reader = new DataStreamReader(sendArray); reader.ReadByte(); reader.ReadUShort(); var len = reader.ReadUShort() + msgHeaderLen + 1; if (len > tmp.Capacity) { sendBuffer.Clear(); // Could not fit a single message in the packet, this is a serious error throw new InvalidOperationException("An RPC was too big to be sent, reduce the size of your RPCs"); } tmp.WriteBytes((byte *)sendBuffer.GetUnsafePtr(), len); // Try to fit a few more messages in this packet while (true) { var subArray = sendArray.GetSubArray(tmp.Length, sendArray.Length - tmp.Length); reader = new DataStreamReader(subArray); reader.ReadUShort(); len = reader.ReadUShort() + msgHeaderLen; if (tmp.Length + len > tmp.Capacity) { break; } tmp.WriteBytes((byte *)subArray.GetUnsafeReadOnlyPtr(), len); } } else { tmp.WriteBytes((byte *)sendBuffer.GetUnsafePtr(), sendBuffer.Length); } // If sending failed we stop and wait until next frame if (driver.EndSend(tmp) <= 0) { break; } if (tmp.Length < sendBuffer.Length) { // Compact the buffer, removing the rpcs we did send for (int cpy = tmp.Length; cpy < sendBuffer.Length; ++cpy) { sendBuffer[1 + cpy - tmp.Length] = sendBuffer[cpy]; } // Remove all but the first byte of the data we sent, first byte is identifying the packet as an rpc sendBuffer.ResizeUninitialized(1 + sendBuffer.Length - tmp.Length); } else { sendBuffer.Clear(); } } } }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); StartHP = reader.ReadUShort(); }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); DeniedMessageID = reader.ReadInt(); }
public void Deserialize(uint tick, ref DataStreamReader reader, CubeInput baseline, NetworkCompressionModel compressionModel) { Deserialize(tick, ref reader); }
public virtual void Deserialize(DataStreamReader reader) { }
public abstract IParameters DeserializeParameters(ref DataStreamReader reader);
public void Deserialize(ref DataStreamReader reader) { value = reader.ReadInt(); }
public void Deserialize(uint tick, ref PilotSnapshotData baseline, ref DataStreamReader reader, NetworkCompressionModel compressionModel) { this.tick = tick; changeMask0 = reader.ReadPackedUIntDelta(baseline.changeMask0, compressionModel); if ((changeMask0 & (1 << 0)) != 0) { CameraRigChildheadPoseX = reader.ReadPackedIntDelta(baseline.CameraRigChildheadPoseX, compressionModel); CameraRigChildheadPoseY = reader.ReadPackedIntDelta(baseline.CameraRigChildheadPoseY, compressionModel); CameraRigChildheadPoseZ = reader.ReadPackedIntDelta(baseline.CameraRigChildheadPoseZ, compressionModel); } else { CameraRigChildheadPoseX = baseline.CameraRigChildheadPoseX; CameraRigChildheadPoseY = baseline.CameraRigChildheadPoseY; CameraRigChildheadPoseZ = baseline.CameraRigChildheadPoseZ; } if ((changeMask0 & (1 << 1)) != 0) { CameraRigChildheadRotX = reader.ReadPackedIntDelta(baseline.CameraRigChildheadRotX, compressionModel); CameraRigChildheadRotY = reader.ReadPackedIntDelta(baseline.CameraRigChildheadRotY, compressionModel); CameraRigChildheadRotZ = reader.ReadPackedIntDelta(baseline.CameraRigChildheadRotZ, compressionModel); CameraRigChildheadRotW = reader.ReadPackedIntDelta(baseline.CameraRigChildheadRotW, compressionModel); } else { CameraRigChildheadRotX = baseline.CameraRigChildheadRotX; CameraRigChildheadRotY = baseline.CameraRigChildheadRotY; CameraRigChildheadRotZ = baseline.CameraRigChildheadRotZ; CameraRigChildheadRotW = baseline.CameraRigChildheadRotW; } if ((changeMask0 & (1 << 2)) != 0) { CameraRigChildleftHandPoseX = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandPoseX, compressionModel); CameraRigChildleftHandPoseY = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandPoseY, compressionModel); CameraRigChildleftHandPoseZ = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandPoseZ, compressionModel); } else { CameraRigChildleftHandPoseX = baseline.CameraRigChildleftHandPoseX; CameraRigChildleftHandPoseY = baseline.CameraRigChildleftHandPoseY; CameraRigChildleftHandPoseZ = baseline.CameraRigChildleftHandPoseZ; } if ((changeMask0 & (1 << 3)) != 0) { CameraRigChildleftHandRotX = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandRotX, compressionModel); CameraRigChildleftHandRotY = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandRotY, compressionModel); CameraRigChildleftHandRotZ = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandRotZ, compressionModel); CameraRigChildleftHandRotW = reader.ReadPackedIntDelta(baseline.CameraRigChildleftHandRotW, compressionModel); } else { CameraRigChildleftHandRotX = baseline.CameraRigChildleftHandRotX; CameraRigChildleftHandRotY = baseline.CameraRigChildleftHandRotY; CameraRigChildleftHandRotZ = baseline.CameraRigChildleftHandRotZ; CameraRigChildleftHandRotW = baseline.CameraRigChildleftHandRotW; } if ((changeMask0 & (1 << 4)) != 0) { CameraRigChildrightHandPoseX = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandPoseX, compressionModel); CameraRigChildrightHandPoseY = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandPoseY, compressionModel); CameraRigChildrightHandPoseZ = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandPoseZ, compressionModel); } else { CameraRigChildrightHandPoseX = baseline.CameraRigChildrightHandPoseX; CameraRigChildrightHandPoseY = baseline.CameraRigChildrightHandPoseY; CameraRigChildrightHandPoseZ = baseline.CameraRigChildrightHandPoseZ; } if ((changeMask0 & (1 << 5)) != 0) { CameraRigChildrightHandRotX = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandRotX, compressionModel); CameraRigChildrightHandRotY = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandRotY, compressionModel); CameraRigChildrightHandRotZ = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandRotZ, compressionModel); CameraRigChildrightHandRotW = reader.ReadPackedIntDelta(baseline.CameraRigChildrightHandRotW, compressionModel); } else { CameraRigChildrightHandRotX = baseline.CameraRigChildrightHandRotX; CameraRigChildrightHandRotY = baseline.CameraRigChildrightHandRotY; CameraRigChildrightHandRotZ = baseline.CameraRigChildrightHandRotZ; CameraRigChildrightHandRotW = baseline.CameraRigChildrightHandRotW; } if ((changeMask0 & (1 << 6)) != 0) { PilotDataPlayerId = reader.ReadPackedIntDelta(baseline.PilotDataPlayerId, compressionModel); } else { PilotDataPlayerId = baseline.PilotDataPlayerId; } if ((changeMask0 & (1 << 7)) != 0) { RotationValueX = reader.ReadPackedIntDelta(baseline.RotationValueX, compressionModel); RotationValueY = reader.ReadPackedIntDelta(baseline.RotationValueY, compressionModel); RotationValueZ = reader.ReadPackedIntDelta(baseline.RotationValueZ, compressionModel); RotationValueW = reader.ReadPackedIntDelta(baseline.RotationValueW, compressionModel); } else { RotationValueX = baseline.RotationValueX; RotationValueY = baseline.RotationValueY; RotationValueZ = baseline.RotationValueZ; RotationValueW = baseline.RotationValueW; } if ((changeMask0 & (1 << 8)) != 0) { TranslationValueX = reader.ReadPackedIntDelta(baseline.TranslationValueX, compressionModel); TranslationValueY = reader.ReadPackedIntDelta(baseline.TranslationValueY, compressionModel); TranslationValueZ = reader.ReadPackedIntDelta(baseline.TranslationValueZ, compressionModel); } else { TranslationValueX = baseline.TranslationValueX; TranslationValueY = baseline.TranslationValueY; TranslationValueZ = baseline.TranslationValueZ; } }
private void OnData(DataStreamReader stream, int connectionIndex) { NativeArray <byte> bytes = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(bytes); string returnData = Encoding.ASCII.GetString(bytes.ToArray()); if (returnData == "heartbeat") { return; } NetworkHeader header = JsonUtility.FromJson <NetworkHeader>(returnData); switch (header.cmd) { case Command.Click: { Debug.Log("Click"); Click click = JsonUtility.FromJson <Click>(returnData); bool validClick = false; Result result = new Result(); switch (click.mouse) { case 0: //TODO collect result validClick = GridManager.instance.ClickAt(click.index, ref result); break; case 1: //TODO collect result validClick = GridManager.instance.FlagAt(click.index, ref result); break; default: Debug.Log("Nothing happens"); break; } SendResult(result); if (result.result.Count > 0) { if (result.result[0].status == Cell.Status.MINE) { Time.timeScale = 0.0f; } } if (validClick) { NotifyTurn(((connectionIndex + 1) % 2)); } else { NotifyTurn(connectionIndex); } } break; case Command.Chat: Chat chat = JsonUtility.FromJson <Chat>(returnData); chat.chatMessage = chat.RemoveQuestionMark(chat.chatMessage); Debug.Log("Chat message : " + chat.chatMessage); SendData(chat); break; default: break; } }
protected abstract void Read(DataStreamReader stream);
private void OnData(DataStreamReader stream, int i) { //Convert our stream into bytes NativeArray <byte> bytes = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(bytes); //Convert byte into string data string recMsg = Encoding.ASCII.GetString(bytes.ToArray()); //Convert data string into json object, and convert it into c# class NetworkHeader header = JsonUtility.FromJson <NetworkHeader>(recMsg); //convert json message into appropriate c# objects switch (header.cmd) { case Commands.HANDSHAKE: HandshakeMsg hsMsg = JsonUtility.FromJson <HandshakeMsg>(recMsg); Debug.Log("[Notice] Handshake message received!"); break; case Commands.PLAYER_UPDATE: PlayerUpdateMsg puMsg = JsonUtility.FromJson <PlayerUpdateMsg>(recMsg); //Debug.Log("[Routine] Player update message received!"); //Update player data if (m_clientIDDict.ContainsKey(m_Connections[i].InternalId)) { m_clientIDDict[m_Connections[i].InternalId].cubePosition = puMsg.player.cubePosition; m_clientIDDict[m_Connections[i].InternalId].cubeOrientation = puMsg.player.cubeOrientation; } else { Debug.LogError("[Error] Given InternalId is not a key in m_clientIDDict; Cannot update player data."); } break; case Commands.SERVER_UPDATE: //TODO: remove this. This is not needed because the server isn't going to send a message to itself Debug.LogError("[Error] Server update message received! The server shouldn't receive Commands.SERVER_UPDATE."); break; case Commands.PING: if (m_clientIDDict.ContainsKey(m_Connections[i].InternalId)) { //Debug.Log("[Routine] Ping received from " + m_Connections[i].InternalId + " (InternalId) " + m_clientIDDict[m_Connections[i].InternalId].clientID + " (clientID)"); PongClientResponse(i); // Send back Pong message } else { Debug.LogError("[Error] Ping received, but given InternalId (" + m_Connections[i].InternalId + ") is not a key in m_clientIDDict. Aborting Pong response..."); } break; case Commands.CLIENT_HANDSHAKE: HandshakeMsg chsMsg = JsonUtility.FromJson <HandshakeMsg>(recMsg); if (m_clientIDDict.ContainsKey(m_Connections[i].InternalId)) { Debug.Log("[Notice] Handshake from client received! " + m_Connections[i].InternalId + " (InternalId) " + m_clientIDDict[m_Connections[i].InternalId].clientID + " (clientID)"); //Update client player data m_clientIDDict[m_Connections[i].InternalId].cubePosition = chsMsg.player.cubePosition; m_clientIDDict[m_Connections[i].InternalId].cubeOrientation = chsMsg.player.cubeOrientation; m_clientIDDict[m_Connections[i].InternalId].cubeColor = Color.white; m_clientIDDict[m_Connections[i].InternalId].bUnassignedData = false; Debug.Log("clientID: " + m_clientIDDict[m_Connections[i].InternalId].clientID); SendServerHandshake(i, m_clientIDDict[m_Connections[i].InternalId].clientID); //Send back handshake UpdateClientsWithNewPlayer(i); //Send all connected clients the new player data } else { Debug.LogError("[Error] Handshake received, but given InternalId (" + m_Connections[i].InternalId + ") is not a key in m_clientIDDict. Aborting handshake response..."); } break; default: Debug.LogError("[Error] SERVER ERROR: Unrecognized message received!"); break; } }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); Direction = reader.ReadByte(); }
public virtual void DeserializeObject(ref DataStreamReader reader) { ID = reader.ReadUInt(); }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); PlayerAttackingID = reader.ReadInt(); DamageDealt = reader.ReadUShort(); }
void OnData(DataStreamReader stream) { NativeArray <byte> bytes = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(bytes); string recMsg = Encoding.ASCII.GetString(bytes.ToArray()); NetworkHeader header = JsonUtility.FromJson <NetworkHeader>(recMsg); switch (header.cmd) { case Commands.HANDSHAKE: HandshakeMsg hsMsg = JsonUtility.FromJson <HandshakeMsg>(recMsg); Debug.Log("Handshake message received!"); break; case Commands.PLAYER_UPDATE: PlayerUpdateMsg puMsg = JsonUtility.FromJson <PlayerUpdateMsg>(recMsg); Debug.Log("Player update message received!"); break; case Commands.SERVER_UPDATE: ServerUpdateMsg suMsg = JsonUtility.FromJson <ServerUpdateMsg>(recMsg); Debug.Log("Server update message received!"); for (int i = 0; i < suMsg.players.Count; ++i) { Debug.Log(suMsg.players[i].id + " " + suMsg.players[i].cubPos); } // server가 보내주는 모든 정보 받기, 현교 데이터만 받아와서 내 업데이트에 적용 // -> get all data from server, and only update other clients(updates)' data to my update UpdateOldClientsInfo(suMsg); break; case Commands.INTERNAL_ID: // get internal id from server PlayerUpdateMsg internalID = JsonUtility.FromJson <PlayerUpdateMsg>(recMsg); //Debug.Log(internalID.player.id); id = internalID.player.id; break; case Commands.OLD_CLIENTS_INFO: // get old clients info from server ServerUpdateMsg oldClientsInfo = JsonUtility.FromJson <ServerUpdateMsg>(recMsg); //for(int i = 0; i < oldClientsInfo.players.Count; ++i) //{ // Debug.Log(oldClientsInfo.players[i].id); //} // spawn old clients SpawnOldClients(oldClientsInfo); break; case Commands.NEW_CLIENTS_INFO: PlayerUpdateMsg newClientsInfo = JsonUtility.FromJson <PlayerUpdateMsg>(recMsg); // spawn new client SpawnNewClients(newClientsInfo); break; case Commands.DISCONNECTED: DeleteMsg dm = JsonUtility.FromJson <DeleteMsg>(recMsg); // destroy method DestoryDisconnected(dm); break; default: Debug.Log("Unrecognized message received!"); break; } }
public NetMessage(DataStreamReader reader) { this.reader = reader; }
public async Task StartClient() { if (isStarted) { return; } isStarted = true; isHost = false; client = new UdpClient(broadcastPort); Debug.Log("Broadcast StartClient"); while (true) { if (isStarted) { var result = await client.ReceiveAsync(); var responseBytes = result.Buffer; if (responseBytes == null || responseBytes.Length == 0) { continue; } using (var writer = new DataStreamWriter(responseBytes.Length, Allocator.Temp)) { unsafe { fixed(byte *data = responseBytes) { writer.WriteBytes(data, responseBytes.Length); var reader = new DataStreamReader(writer, 0, writer.Length); var ctx = default(DataStreamReader.Context); var key = reader.ReadInt(ref ctx); var version = reader.ReadInt(ref ctx); if (key != m_broadcastKey) { return; } if (version != m_broadcastVersion) { return; } var str = reader.ReadString(ref ctx); //Debug.Log ("OnReciveBroadcast key=" + key + ", version=" + version + ", str=" + str + "time=" + Time.time); OnReciveBroadcast?.Invoke(result.RemoteEndPoint, key, version, str); //Stop (); } } } } else { break; } } if (client != null) { client.Close(); client = null; } }
public void Deserialize(ref DataStreamReader reader) { CountdownSeconds = reader.ReadUIntNetworkByteOrder(); }
public static void EchoText(DataStreamReader stream) { var text = stream.ReadString(); Debug.Log(text); }
public void Setup() { reader = new DataStreamReader(); writer = new DataStreamWriter(m_Buffer.Length, Unity.Collections.Allocator.Temp); }
public static void HelloReceived(DataStreamReader stream) { var text = stream.ReadString(); Debug.Log(text); }
public void Deserialize(uint tick, ref DataStreamReader reader) { this.tick = tick; horizontal = reader.ReadInt(); vertical = reader.ReadInt(); }
public void Deserialize(ref DataStreamReader reader) { }
public void Deserialize(DataStreamReader reader, ref DataStreamReader.Context ctx) { }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); TreasureAmount = reader.ReadUShort(); }
public override void Read(int connectionId, DataStreamReader stream, ref DataStreamReader.Context context) { var id = stream.ReadInt(ref context); var client = GetComponentInParent <ClientBehaviour>(); }
//IEnumerator SendInput() //{ // while(true) // { // yield return new WaitForSeconds(2); // Debug.Log("Sending player input"); // PlayerInputMsg m = new PlayerInputMsg(); // } //} void OnData(DataStreamReader stream) { NativeArray <byte> bytes = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(bytes); string recMsg = Encoding.ASCII.GetString(bytes.ToArray()); NetworkHeader header = JsonUtility.FromJson <NetworkHeader>(recMsg); switch (header.cmd) { case Commands.HANDSHAKE: HandshakeMsg hsMsg = JsonUtility.FromJson <HandshakeMsg>(recMsg); newID = hsMsg.player.id; hsMsg.player.playerCube = Instantiate(cube); playerList.Add(hsMsg.player); Debug.Log("Handshake message received!"); break; case Commands.PLAYER_UPDATE: PlayerUpdateMsg puMsg = JsonUtility.FromJson <PlayerUpdateMsg>(recMsg); Debug.Log("Player update message received!"); break; case Commands.SERVER_UPDATE: ServerUpdateMsg suMsg = JsonUtility.FromJson <ServerUpdateMsg>(recMsg); //sync cube pos to players here Debug.Log("Num clients connected: " + suMsg.players.Count); foreach (NetworkObjects.NetworkPlayer player in suMsg.players) { if (player.id != newID) // if the player is me skip the update { int index = -1; for (int i = 0; i < playerList.Count; i++) { if (playerList[i].id == player.id) { index = i; playerList[index].cubPos = player.cubPos; //playerList[index].playerCube.GetComponent<Renderer>().material.color = player.cubeColor; playerList[index].playerCube.transform.position = player.cubPos; playerList[index].cubeColor = player.cubeColor; } } //int index = playerList.IndexOf(player); Debug.Log("first Index num: " + index); if (index == -1) // no player id in player list { index = playerList.Count; NetworkObjects.NetworkPlayer temp = new NetworkObjects.NetworkPlayer(); temp.id = player.id; temp.playerCube = Instantiate(cube); temp.cubPos = player.cubPos; temp.playerCube.GetComponent <Renderer>().material.color = player.cubeColor; temp.playerCube.transform.position = player.cubPos; temp.cubeColor = player.cubeColor; playerList.Add(temp); index = playerList.IndexOf(player); Debug.Log("second Index num: " + index); //playerList[index].playerCube = player.playerCube; } } // update the player cube } Debug.Log("Server update message received!"); break; default: Debug.Log("Unrecognized message received!"); break; } }
public override void DeserializeObject(ref DataStreamReader reader) { base.DeserializeObject(ref reader); PlayerID = reader.ReadInt(); }
internal void RecieveBehaviourRpcInGroup(ushort senderPlayerId, ushort netId, ref DataStreamReader recievePacket, ref DataStreamReader.Context ctx) { if (netId < m_identityList.Count) { var identity = m_identityList[netId]; if (identity != null) { identity.OnRecieveRpcPacket(senderPlayerId, ref recievePacket, ref ctx); } } }