예제 #1
0
        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);
            }
        }
예제 #2
0
파일: GOD.cs 프로젝트: gallobonts/portfolio
    private IEnumerator TimerCoroutine(float time, voidDelegate methodToCall)
    {
        yield return(new WaitForSeconds(time));

        methodToCall.Invoke();
    }