private void OnPacketReceived(Packet packet) { if (packet is PingPacket pingPacket) { PingResponsePacket pingResponsePacket = new PingResponsePacket(pingPacket.GetPingId()); karmanClient.Send(pingResponsePacket); } }
protected void FixedUpdate() { foreach (var character in characters.Values) { if (character.RequestPositionSyncCheck()) { CharacterUpdatePositionPacket characterUpdatePositionPacket = character.GetUpdatePositionPacket(); karmanClient.Send(characterUpdatePositionPacket); } } }
public void Update() { if (karmanClient.IsConnected() && sendConnectionMessages) { float connectedTime = Time.timeSinceLevelLoad; if (connectedTime > connectedTimeAtLastSend + sendConnectionMessagesInterval) { connectedTimeAtLastSend = Time.timeSinceLevelLoad; karmanClient.Send(new MessagePacket(string.Format( "{0} has been connected for {1} second(s).", karmanClient.id, connectedTime.ToString("0") ))); } } }
protected override void Request(MutationPacket mutationPacket, Mutation mutation) { client.Send(mutationPacket); pending.Add(mutationPacket.GetId(), $"{mutation.GetType().Name} on fragment[{fragmentKeyFactory.FromBytes(mutationPacket.GetKey()).AsString()}].\nStackTrace: {Environment.StackTrace}"); }