private void OnServerMessage(object sender, MessageEventArgs e) { var json = JObject.Parse(e.Data.ToString()); if (json["sender_type"].ToString() == "user" && json["msg_type"].ToString() == "command" && json["msg_content"]["printer_name"].ToString() == PrinterName) { var jsonCommand = json["msg_content"]["command_name"].ToString(); switch (jsonCommand) { case "Command1": ExecuteCommand1?.Invoke(); break; case "Command2": ExecuteCommand2?.Invoke(); break; case "Command3": ExecuteCommand3?.Invoke(); break; case "Command4": ExecuteCommand4?.Invoke(); break; } AddLog("\"" + json["sender_name"].ToString() + "\": " + jsonCommand); } else if (json["sender_type"].ToString() == "server" && json["msg_type"].ToString() == "token" && json["msg_content"]["printer_name"].ToString() == PrinterName) { m_token = json["msg_content"]["token"].ToString(); AddLog("\"" + json["sender_name"].ToString() + "\": " + m_token); } }
private IEnumerator TimerCoroutine(float time, voidDelegate methodToCall) { yield return(new WaitForSeconds(time)); methodToCall.Invoke(); }