当前位置: 首页>>代码示例>>C#>>正文


C# IHubProxy.Subscribe方法代码示例

本文整理汇总了C#中IHubProxy.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# IHubProxy.Subscribe方法的具体用法?C# IHubProxy.Subscribe怎么用?C# IHubProxy.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHubProxy的用法示例。


在下文中一共展示了IHubProxy.Subscribe方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupHub

 private async void SetupHub()
 {
     _hubConnection = new Microsoft.AspNet.SignalR.Client.HubConnection("http://localhost:1331/");
     _auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
     _auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
     await _hubConnection.Start();
 }
开发者ID:asifashraf,项目名称:proSignalR,代码行数:9,代码来源:MainPage.xaml.cs

示例2: StartHub

 async void StartHub()
 {
     _hubConnection = new HubConnection("http://192.168.1.148:1331/signalr");
     _auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
     _auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
     await _hubConnection.Start();
 }
开发者ID:asifashraf,项目名称:proSignalR,代码行数:9,代码来源:MainActivity.cs

示例3: SetupHub

 private async void SetupHub()
 {
     _updateDelegate = new UpdateBid(UpdateBidMethod);
     _updateButtonsDelegate = new UpdateButtons(UpdateButtonsMethod);
     _hubConnection = new HubConnection("http://192.168.1.148:1331/");
     _auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
     _auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
     await _hubConnection.Start();
 }
开发者ID:asifashraf,项目名称:proSignalR,代码行数:11,代码来源:MainPage.xaml.cs

示例4: StartSignalR

    void StartSignalR()
    {
        if (_hubConnection == null)
        {
            _hubConnection = new HubConnection(signalRUrl);

            _hubProxy = _hubConnection.CreateProxy("MyHub");
            _subscription = _hubProxy.Subscribe("executeCommand");
            _subscription.Data += data =>
            {
                Debug.Log(data[0].ToString());

                var message = Newtonsoft.Json.JsonConvert.DeserializeObject<Message>(data[0].ToString());

                ActionTrigger = message;
            };
            try
            {
                _hubConnection.Start();
            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            Debug.Log("Signalr already connected...");
        }
    }
开发者ID:valeryjacobs,项目名称:TIMTLTS,代码行数:30,代码来源:SignalRController.cs

示例5: Init

        private async void Init()
        {
            _connection = new HubConnection("http://localhost:54506");
            _hub = _connection.CreateHubProxy("chatty");
            _hub.Subscribe("spoke").Data += tokens =>
                                                {
                                                    var name = tokens[0].ToString();
                                                    var message = tokens[1].ToString();
                                                    AddMessage(name, message);
                                                };

            await _connection.Start();
            await _hub.Invoke("setName", "Win8Tomas");
        }
开发者ID:mastoj,项目名称:SignalRPres,代码行数:14,代码来源:ChattyClient.cs

示例6: StartSignalR

    void StartSignalR()
    {
        if (_hubConnection == null)
        {
            _hubConnection = new HubConnection(signalRUrl);

            _hubProxy = _hubConnection.CreateProxy("SignalRSampleHub");
            _subscription = _hubProxy.Subscribe("broadcastMessage");
            _subscription.Data += data =>
            {
                Debug.Log("signalR called us back");
            };
            _hubConnection.Start();
        }
        else
            Debug.Log("Signalr already connected...");

    }
开发者ID:BerndtHamboeck,项目名称:UnitySignalRVS2013,代码行数:18,代码来源:SignalRUnityController.cs

示例7: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            SetStatus("Connecting");
            connection = new HubConnection("http://localhost:8080/chatserver", false);

            myHub = connection.CreateHubProxy("ChatHub");

            frmLogin login = new frmLogin(myHub);
            login.ShowDialog();

            connection.Start().ContinueWith(task =>
            {
            if (task.IsFaulted == false)
            {
                if (connection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
                {
                    SetStatus("Connected");

                    myHub.Invoke("Join", login.Username).ContinueWith(task_join =>
                    {
                        if (task_join.IsFaulted)
                        {
                            MessageBox.Show("Error during joining the server!");
                        }
                        else
                        {
                            Subscription sub = myHub.Subscribe("addMessage");
                            sub.Data += args =>
                            {
                                Message(args[0].ToString());
                            };

                            UpdateUsers();

                            timer1.Enabled = true;
                        }
                    });
                }

            }

            });
        }
开发者ID:Veloursnebel,项目名称:SignalRChat,代码行数:43,代码来源:Form1.cs

示例8: Connect

        public async static void Connect()
        {
            var connection = new HubConnection("http://pbclone.azurewebsites.net/");
            //var connection = new HubConnection("http://localhost:4341/");
            _mainHub = connection.CreateHubProxy("imghub");

            await connection.Start().ContinueWith(_ =>
                                                {
                                                    _mainHub.Invoke("Create", "test");
                                                    //_mainHub.Invoke("SendMsg", "test ok");
                                                    //_mainHub.Subscribe("receiveMsg").Data += tokens => Console.WriteLine(tokens[0]);
                                                    _mainHub.Subscribe("ReceiveImage").Data += tokens =>
                                                                                                   {
                                                                                                       byte[] convertedFromBase64 = Convert.FromBase64String(tokens[0].ToString());

                                                                                                       Console.WriteLine
                                                                                                           (convertedFromBase64.Length);
                                                                                                   };
                                                    _mainHub.Invoke("ShareImage", new object[] { new byte[] { 1, 2 }, "test" });
                                                });
        }
开发者ID:NicoVermeir,项目名称:photobeamerclone,代码行数:21,代码来源:Program.cs

示例9: SubscribeToMessages

 protected override void SubscribeToMessages(IHubProxy proxy)
 {
     proxy.Subscribe("RoomEntered").Data += RoomChange;
     proxy.Subscribe("RoomExited").Data += RoomChange;
     proxy.Subscribe("OnPlayerTrapped").Data += (object[] args) =>
     {
         CaughtMessages.Enqueue(new HeistCaughtMessage()
         {
             Tag = IncomingMessageType.OpponentTrapped,
             PlayerId = args[0] as string,
             OpponentId = args[1] as string
         });
     };
     proxy.Subscribe("OpponentCaught").Data += (object[] args) =>
     {
         CaughtMessages.Enqueue(new HeistCaughtMessage()
         {
             Tag = IncomingMessageType.OpponentCaught,
             PlayerId = args[0] as string,
             OpponentId = args[1] as string,
         });
     };
     proxy.Subscribe("NeedUpdate").Data += (object[] args) =>
     {
         NeedsUpdate();
     };
     proxy.Subscribe("GameFinished").Data += (object[] args) =>
     {
         UnityEngine.Debug.Log("GAME FINISHED!");
         CaughtMessages.Enqueue(new HeistCaughtMessage()
         {
             Tag = IncomingMessageType.OpponentCaught,
             PlayerId = args[0] as string
         });
     };
     proxy.Subscribe("GameReady").Data += (object[] args) =>
     {
         UnityEngine.Debug.Log("EVERYONE JOINED!");
         CaughtMessages.Enqueue(new HeistCaughtMessage()
         {
             Tag = IncomingMessageType.GameReady,
             StartTime = ((DateTime)args[0])
         });
     };
 }
开发者ID:mtsouris81,项目名称:building-heist,代码行数:45,代码来源:HamburglarMessagingClient.cs

示例10: makeConnection

        async private void makeConnection()
        {
            try
            {
                // Pass parameter form client to server.
                var querystringData = new Dictionary<string, string>();
                querystringData.Add("chatversion", "1.1");

                var hubConnection = new HubConnection("http://localhost:53748",querystringData);
               
                // Windows authentication.
                    hubConnection.Credentials = CredentialCache.DefaultCredentials;
                // Connection Header.
              //  hubConnection.Headers.Add("myauthtoken", /* token data */);
                //// Auth(Certificate).
                //hubConnection.AddClientCertificate(X509Certificate.CreateFromCertFile("MyCert.cer"));

                chat = hubConnection.CreateHubProxy("ChatHub");
                chatShow.Text = "";
                Context = SynchronizationContext.Current;
                
                chat.On<string, string>("broadcastMessage",
                    (name, message) =>
                        Context.Post(delegate
                        {
                            this.chatShow.Text += name + ": "; this.chatShow.Text += message + "\n";
                        }, null)
                        );
              
                chat.Subscribe("notifyWrongVersion").Received += notifyWrongVersion_chat;
               

                
                await hubConnection.Start();
                await chat.Invoke("Notify", chatName.Text, hubConnection.ConnectionId);
            }
            catch (HubException ex)
            {

            }
            catch (Exception ex)
            {

            }
        }
开发者ID:devnarayan,项目名称:Sample-applications---SignalR,代码行数:45,代码来源:HubPage.xaml.cs

示例11: SetupHandlers

 public override void SetupHandlers(IHubProxy proxy)
 {
     proxy.Subscribe("send").Received += EchoUser_Received;
 }
开发者ID:Cybermaxs,项目名称:SignalR.Hubs.StressClient,代码行数:4,代码来源:EchoUser.cs


注:本文中的IHubProxy.Subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。