void FixedUpdate() { clientInstance.PollEvents(); var peer = clientInstance.GetFirstPeer(); if (peer != null && peer.ConnectionState == ConnectionState.Connected) { // do something here } else { clientInstance.SendDiscoveryRequest(new byte[] { 1 }, 5000); } writer.Reset(); bool inputed = false; if (connectedServer != null) { List <int> Keys = new List <int> (); writer.Reset(); foreach (var key in RegionKecode) { if (Input.GetKeyDown(key)) { inputed = true; Keys.Add((int)key); Debug.Log("IN " + (int)key); } } if (inputed) { ClientInput input = new ClientInput(); input.ToogledBtn = Keys.ToArray(); input.ClinetID = clientInstance.LocalPort; input.Serialize(writer); peer.Send(writer, DeliveryMethod.Sequenced); Keys = null; } } }
public void Serialize(NetDataWriter writer) { writer.Put(ClientInput.Serialize(this)); }