Exemplo n.º 1
0
        public ChatClient()
        {
            this.conn     = new HubConnection(HubUrl);
            this.hubProxy = this.conn.CreateProxy("chat");

            //注册客户端接口
            this.hubProxy.Subscribe("onMessageReceive").Data += data =>
            {
                if (data == null || data.Length <= 0)
                {
                    return;
                }
                MessageReceiveEventArgs e = new MessageReceiveEventArgs();
                e.ClientID = Convert.ToString(data[0]);
                e.Message  = Convert.ToString(data[1]);
                this.OnMessageReceive(e);
            };

            this.hubProxy.Subscribe("onBuddyLogin").Data += data =>
            {
                if (data == null || data.Length <= 0)
                {
                    return;
                }
            };
        }
Exemplo n.º 2
0
 protected void OnMessageReceive(MessageReceiveEventArgs e)
 {
     if (this.MessageReceive != null)
     {
         this.MessageReceive(this, e);
     }
 }