public void init() { server = new CtServer(ipi.text, 9000); server.OnChangeUser += Server_OnChangeUser; server.OnError += Server_OnError; server.OnNewRoom += Server_OnNewRoom; StartCoroutine(StartPing(ipi.text)); }
void sendPack(Dictionary <string, object> valuePairs) { //string json = JsonUtility.ToJson(valuePairs); string json = CtServer.ConvertDictionaryToJsonHard(valuePairs); Debug.Log(json); byte[] data = Encoding.UTF8.GetBytes(json); stream.Write(data, 0, data.Length); }
public void init() { server = new CtServer(ipi.text.Split(':')[0], int.Parse(ipi.text.Split(':')[1])); idi.text = id = server.GetMacAddress(); server.OnChangeUser += Server_OnChangeUser; server.OnError += Server_OnError; server.OnNewRoom += Server_OnNewRoom; StartCoroutine(UdpateTransform()); }
private Dictionary <string, object> Udpate() { while (true) { State so = new State(); int bytes = stream.Read(so.buffer, 0, so.buffer.Length); if (bytes != 0) { Debug.Log($"Pack size: {bytes} byte"); return(CtServer.ByteJsonToDictionaryHard(so.buffer, bytes)); } } }