示例#1
0
        public void SignUp(string user_name, WebCallBack webCallBack)
        {
            client.Subscribe("/user/" + user_name + "/greetings", (string msg) =>
            {
                ReceiveMessage receive = JsonConvert.DeserializeObject <ReceiveMessage>(msg);
                if (receive.type == "Accept-login")
                {
                    webCallBack(true, receive.sender, receive.content);
                    userName = receive.content;
                    Debug.Log("Set user name: " + receive.content);
                    Login();
                }
                else if (receive.type == "Reject-login")
                {
                    webCallBack(false, receive.sender, receive.content);
                }
                else
                {
                    Debug.LogError("Unknown type " + receive.type);
                }

                client.Unsubscribe("/user/" + user_name + "/greeting");
            });
            client.Send("/app/hello/" + user_name, JsonConvert.SerializeObject(new SendMessage(user_name, "", "")));
        }
示例#2
0
 private void JoinRoom(string room_name, WebCallBack webCallBack)
 {
     client.Subscribe("/topic/" + room_name + "/ready", (string msg) =>
     {
         ReceiveMessage receiveMessage = JsonConvert.DeserializeObject <ReceiveMessage>(msg);
         webCallBack(true, receiveMessage.sender, receiveMessage.content);
     });
     room = room_name;
 }
        public frmModifySite() //主窗体构造函数
        {
            InitializeComponent();
            web.Address = Global.WebURL + "coordinate.php";
            var boundObj = new WebCallBack(this);

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            CefSharpSettings.WcfEnabled = true;
            web.JavascriptObjectRepository.Register("bound", boundObj, isAsync: false);
            web.FrameLoadEnd += boundObj.OnFrameLoadEnd;
            RefreshList();
            CreateSiteGUI();
        }
示例#4
0
 public void TryJoinRoom(string room_name, WebCallBack joinCallBack, WebCallBack readyCallBack)
 {
     client.Subscribe("/topic/" + room_name, (string msg) =>
     {
         ReceiveMessage receive = JsonConvert.DeserializeObject <ReceiveMessage>(msg);
         if (receive.type == "Accept-room.addUser")
         {
             joinCallBack(true, receive.sender, receive.content);
             JoinRoom(room_name, readyCallBack);
         }
         else if (receive.type == "Reject-room.addUser")
         {
             joinCallBack(false, receive.sender, receive.content);
         }
         else
         {
             Debug.LogError("Unknown type " + receive.type);
         }
     });
     client.Send("/app/room.addUser", JsonConvert.SerializeObject(new SendMessage(userName, room_name, "")));
 }