void Update() { switch (curStep) { case typeStep.Entry: if (windowEntryName.isStepComplete) { windowEntryName.SetActive(false); windowWaiting.SetActive(true, curStep.ToString()); // connect string url = UrlJoin + "?uid=" + userId.ToString() + "&gid=" + windowEntryName.groupId.ToString() + "&name=" + windowEntryName.userName; Debug.Log(url); sock.Connect(url); curStep = typeStep.Connecting; } break; case typeStep.Connecting: if (sock.CanUse) { windowWaiting.SetActive(false); windowChat.SetActive(true); windowChat.ClearRecievedMessage(); curStep = typeStep.Idle; } break; case typeStep.Idle: // do nothing // NOTE : step is changed by leave button. break; case typeStep.Leaving: // if socket close if (sock.IsUnavaiable) { windowWaiting.SetActive(false); windowEntryName.Reset(); windowEntryName.SetActive(true); curStep = typeStep.Entry; } break; default: break; } }
private void callbackLeaveRoom() { /* * byte[] d = BitConverter.GetBytes(true); * byte[] result = makeData(0, d); * sock.Send(result, callbackLeave); */ // leave and close Action <bool> cb = (b) => { sock.Close(); }; sendStatus(0, cb); curStep = typeStep.Leaving; windowChat.SetActive(false); windowWaiting.SetActive(true, curStep.ToString()); }