• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IHubProxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SetHub

 public async Task SetHub(IHubProxy hub)
 {
     this.hub = hub;
     hub.On<string>("info", info => ServedInformation = string.Join("\r\n", ServedInformation, info));
     hub.On("completed", () => _isCompleted = true);
     await hub.Invoke("SetupServer");
 }
开发者ID:Kazuki-Kachi,项目名称:Madoben,代码行数:7,代码来源:MainPageViewModel.cs


示例2: SetHub

        /// <summary>
        /// Hubをセットする
        /// </summary>
        /// <param name="hub"></param>
        public void SetHub(IHubProxy hub)
        {
            if(hub == null) throw new ArgumentNullException(nameof(hub));
            this.hub = hub;
            
            hub.On<string, Type>("serve",async (json, type) =>
              {
                  var noodles = lib.NoodleListConverter.Convert(json, type);
                  if(!noodles.Any()) return;
                  
                  ServedInformation = string.Join("\r\n", ServedInformation, $"{noodles.First().Name}が流れてきたよ!");
                  _flowing = true;

                  try
                  {
                      await Task.Delay(5000);
                      if(!_isPick)
                      {
                          await hub.Invoke("Picking", 0);
                          return;
                      }

                      var pickedCount = Guest.Picking(noodles);
                      ServedInformation = string.Join("\r\n", ServedInformation, Guest.Eat(noodles.Take(pickedCount)));
                      await hub.Invoke("Picking", pickedCount);
                  }
                  finally
                  {
                      _flowing = false;
                      _isPick = false;
                  }
              });
        }
开发者ID:Kazuki-Kachi,项目名称:Madoben,代码行数:37,代码来源:GuestViewModel.cs


示例3: Enviar

        private static void Enviar(IHubProxy _hub, string nome)
        {
            var mensagem = Console.ReadLine();
            _hub.Invoke("Send", nome, mensagem).Wait();

            Enviar(_hub, nome);
        }
开发者ID:viniciusoreis,项目名称:XSP-SignalR,代码行数:7,代码来源:Program.cs


示例4: ConnectAsync

        public void ConnectAsync()
        {
            Connection = new HubConnection("http://54.69.68.144:8733/signalr");
            HubProxy = Connection.CreateHubProxy("ChatHub");
            //Handle incoming event from server: use Invoke to write to console from SignalR's thread

            HubProxy.On<string>("AddMessage", (msg) =>
                    Console.WriteLine("AddMessage Call: " + msg)
            );
            HubProxy.On<string>("GetAllMessage", (s) =>
                    Console.WriteLine(String.Format("{0}: {1}", Environment.NewLine, s))
            );
            HubProxy.On<int>("GetNumberOfUsers",(s) =>
                Console.WriteLine(s)
            )
            ;
            try
            {
                Connection.Start().Wait();
            }
            catch (HttpRequestException)
            {
                Console.WriteLine("Unable to connect to server: Start server before connecting clients.");
            }

            //HubProxy.Invoke("GetAllMessages");
            //await HubProxy.Invoke("GetNumberOfUsers");
        }
开发者ID:unrealdrake,项目名称:eChat,代码行数:28,代码来源:Program.cs


示例5: HubInitial

        public void HubInitial()
        {
            Connection = new HubConnection("http://54.69.68.144:8733/signalr");

            HubProxy = Connection.CreateHubProxy("ChatHub");

            HubProxy.On<string>("AddMessage",(msg) =>
                Device.BeginInvokeOnMainThread(() =>
                {
                   MessageService.AddMessage(msg,false,_controls);
                }));

            HubProxy.On<int>("GetNumberOfUsers", (count) =>
                Device.BeginInvokeOnMainThread(() =>
                {
                    MessageService.SetUsersCount(count, _controls);
                }));

            try
            {
                Connection.Start().Wait();
                Device.BeginInvokeOnMainThread(() =>
                {
                    _controls.ProgressBar.ProgressTo(.9, 250, Easing.Linear);
                });
            }
            catch (Exception e)
            {
                MessageTemplate.RenderError("Невозможно подключиться к серверу");
            }
            HubProxy.Invoke("GetNumberOfUsers");
        }
开发者ID:unrealdrake,项目名称:eChat,代码行数:32,代码来源:HubInitializer.cs


示例6: MainPage

        public MainPage()
        {
            InitializeComponent();

            textBlockMessages.Dispatcher.BeginInvoke(new Action(() => textBlockMessages.Text = "This program, SignalRWp7, begins\n"));

            hubConnection = new HubConnection("http://localhost:49522/");

            hubConnection.Start().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Console.WriteLine("Failed to start: {0}", task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Success! Connected with client connection id {0}", hubConnection.ConnectionId);
                    // Do more stuff here
                }
            });

            hubConnection.Received += data =>
            {
                HubBub deserializedHubBub = JsonConvert.DeserializeObject<HubBub>(data);
                var args0 = deserializedHubBub.Args[0];
                UpdateMessages(args0);
            };

            chatHub = hubConnection.CreateProxy("Chat");
        }
开发者ID:jhalbrecht,项目名称:LearnSignalR,代码行数:30,代码来源:MainPage.xaml.cs


示例7: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     connection = new HubConnection(@"http://iskenxan-001-site1.btempurl.com/signalr");
     myHub = connection.CreateHubProxy("ChatHub");
     UserNameTextBox.Focus();
 }
开发者ID:iskenxan,项目名称:super-octo-chat,代码行数:7,代码来源:LoginWindow.xaml.cs


示例8: Chat

        public Chat(HubConnection connection)
        {
            _chat = connection.CreateHubProxy("Chat");

            _chat.On<User>("markOnline", user =>
            {
                if (UserOnline != null)
                {
                    UserOnline(user);
                }
            });

            _chat.On<User>("markOffline", user =>
            {
                if (UserOffline != null)
                {
                    UserOffline(user);
                }
            });

            _chat.On<Message>("addMessage", message =>
            {
                if (Message != null)
                {
                    Message(message);
                }
            });
        }
开发者ID:xiurui12345,项目名称:MessengR,代码行数:28,代码来源:Chat.cs


示例9: ConnectToServer

        public void ConnectToServer()
        {

            hubConnection = new HubConnection(serverAddress);
            hubProxy = hubConnection.CreateHubProxy("SoftNodesHub");
            bool isConnected = false;
            while (!isConnected)
            {
                try
                {
                    hubConnection.Start().Wait();
                    hubConnection.Closed += OnHubConnectionClosed;
                    //hubProxy.On<Message>("ReceiveMessage", ReceiveMessage);

                    isConnected = true;
                    LogInfo("Connected to server");
                    OnConnected?.Invoke();
                }
                catch (Exception e)
                {
                    LogError("Connection to server failed: " + e.Message);
                    OnConnectionFailed?.Invoke(e.Message);
                }
            }
        }
开发者ID:nickpirrottina,项目名称:MyNetSensors,代码行数:25,代码来源:SoftNodeSignalRTransmitter.cs


示例10: CoordinateHubClient

 public CoordinateHubClient(Action<Coordinate> callback)
 {
     _hubConnection = new HubConnection("http://indoorgps.azurewebsites.net");
     _hubProxy = _hubConnection.CreateHubProxy("CoordinateHub");
     _hubProxy.On<Coordinate>("SendNewCoordinate", callback);
     _hubConnection.Start().Wait();
 }
开发者ID:QiMataTechnologiesInc,项目名称:Presentation-IndoorGPS,代码行数:7,代码来源:CoordinateHubClient.cs


示例11: Connect

 private static void Connect()
 {
     analyticsWebsiteExceptionHubConnection = new HubConnection(analyticsWebsiteConnectionUrl);
     analyticsWebsiteProxy = analyticsWebsiteExceptionHubConnection.CreateHubProxy("ExceptionHub");
     analyticsWebsiteExceptionHubConnection.Start().Wait();
     analyticsWebsiteConnected = true;
 }
开发者ID:ryantomlinson,项目名称:ExceptionMonitor,代码行数:7,代码来源:AnalyticsProxyConnection.cs


示例12: HubConnection

partial         void Application_Initialize()
        {
            HubConnection hubConnection;
            http://localhost:49499
            hubConnection = new HubConnection("http://localhost:49499"); //make sure it matches your port in development

              //  HubProxy = hubConnection.CreateProxy("MyHub");
            HubProxy = hubConnection.CreateHubProxy("Chat");
            HubProxy.On<string, string>("CustomersInserted", (r, user) =>
            {
                this.ActiveScreens.First().Screen.Details.Dispatcher.BeginInvoke(delegate() {
                    this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
                });
              //  this.Details.Dispatcher.BeginInvoke(() =>
              //  {
              //      this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
              ////      Console.WriteLine("Han creat un client");
              //  });
            });

            HubProxy.On<string>("addMessage", (missatge) =>
            {
                this.ActiveScreens.First().Screen.Details.Dispatcher.BeginInvoke(delegate()
                {
                    this.ActiveScreens.First().Screen.ShowMessageBox("has rebut un "+missatge);
                });
                //  this.Details.Dispatcher.BeginInvoke(() =>
                //  {
                //      this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
                ////      Console.WriteLine("Han creat un client");
                //  });
            });
            hubConnection.Start().Wait();
        }
开发者ID:xaviguardia,项目名称:signalrLightSwitch,代码行数:34,代码来源:Application.cs


示例13: GameplayScene

        public GameplayScene(GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            starfield = new Starfield(worldWidth, worldHeight, worldDepth);
            grid = new Grid(worldWidth, worldHeight);
            ShipManager = new ShipManager();
            BulletManager = new BulletManager();
            GameStateManager = new GameStateManager();

            AddActor(ShipManager);
            AddActor(BulletManager);
            AddActor(starfield);
            AddActor(grid);

            #if DEBUG
            hubConnection = new HubConnection("http://localhost:29058");
            #else
            hubConnection = new HubConnection("http://vectorarena.cloudapp.net");
            #endif
            hubProxy = hubConnection.CreateHubProxy("gameHub");
            hubProxy.On("Sync", data => Sync(data));
            hubConnection.Start().ContinueWith(startTask =>
            {
                hubProxy.Invoke<int>("AddPlayer").ContinueWith(invokeTask =>
                {
                    ShipManager.InitializePlayerShip(invokeTask.Result, hubProxy);
                    Camera.TargetObject = ShipManager.PlayerShip;
                    Camera.Position = new Vector3(ShipManager.PlayerShip.Position.X, ShipManager.PlayerShip.Position.Y, 500.0f);
                });
            });
        }
开发者ID:ronforbes,项目名称:VectorArena_bak,代码行数:31,代码来源:GameplayScene.cs


示例14: StartConnection

        private async void StartConnection()
        {
            // Connect to the server
            try
            {
                var hubConnection = new HubConnection("http://192.168.0.43:61893/");

                // Create a proxy to the 'ChatHub' SignalR Hub
                chatHubProxy = hubConnection.CreateHubProxy("ChatHub");

                // Wire up a handler for the 'UpdateChatMessage' for the server
                // to be called on our client
                chatHubProxy.On<string,string>("broadcastMessage", (name, message) => {
                    var str = $"{name}:{message}\n";
                RunOnUiThread(()=>     text.Append( str ) );
                });


                // Start the connection
                await hubConnection.Start();


            }
            catch (Exception e)
            {
                text.Text = e.Message;
            }
        }
开发者ID:Coladela,项目名称:signalr-chat,代码行数:28,代码来源:MainActivity.cs


示例15: CrestLogger

 public CrestLogger()
 {
     var hubConnection = new HubConnection("http://www.contoso.com/");
     errorLogHubProxy = hubConnection.CreateHubProxy("ErrorLogHub");
     //errorLogHubProxy.On<Error>("LogError", error => { });
     hubConnection.Start().Wait();
 }
开发者ID:calvaryccm,项目名称:Crest,代码行数:7,代码来源:CrestLogger.cs


示例16: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();

            DataContext = App.ViewModel;
            var hubConnection = new HubConnection("http://192.168.2.128:50188");
            chat = hubConnection.CreateHubProxy("chat");

            chat.On<string>("newMessage", msg => Dispatcher.BeginInvoke(() => App.ViewModel.Items.Add(new ItemViewModel { LineOne = msg })));

            hubConnection.Error += ex => Dispatcher.BeginInvoke(() =>
                {
                    var aggEx = (AggregateException)ex;
                    App.ViewModel.Items.Add(new ItemViewModel { LineOne = aggEx.InnerExceptions[0].Message });
                });

            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            hubConnection.Start().ContinueWith(task =>
                {
                    var ex = task.Exception.InnerExceptions[0];
                    App.ViewModel.Items.Add(new ItemViewModel { LineOne = ex.Message });
                },
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnFaulted,
                scheduler);
        }
开发者ID:rogertinsley,项目名称:SignalR,代码行数:27,代码来源:MainPage.xaml.cs


示例17: JabbRClient

 public JabbRClient(string url, IClientTransport transport)
 {
     _url = url;
     _connection = new HubConnection(url);
     _chat = _connection.CreateProxy("JabbR.Chat");
     _clientTransport = transport ?? new AutoTransport();
 }
开发者ID:larrybeall,项目名称:JabbR.Client,代码行数:7,代码来源:JabbRClient.cs


示例18: Dispose

 public void Dispose()
 {
     scheduler.Shutdown(true);
     scheduler = null;
     hubProxy = null;
     Logger.loggerInternal = (m) => { Console.WriteLine(m); };
 }
开发者ID:erichexter,项目名称:HomeAutomation,代码行数:7,代码来源:X10AgentService.cs


示例19: Client

        public Client(string platform)
        {
            _platform = platform;

            _connection = new HubConnection("http://meetupsignalrxamarin.azurewebsites.net/");
            _proxy = _connection.CreateHubProxy("ChatHub");
        }
开发者ID:SamukaSantos,项目名称:Xamarin-SignalR-Meetup2,代码行数:7,代码来源:Client.cs


示例20: OpenConnection

        private async Task OpenConnection()
        {
            var url = $"http://{await _serverFinder.GetServerAddressAsync()}/";

            try
            {
                _hubConnection = new HubConnection(url);

                _hubProxy = _hubConnection.CreateHubProxy("device");
                _hubProxy.On<string>("hello", message => Hello(message));
                _hubProxy.On("helloMsg", () => Hello("EMPTY"));
                _hubProxy.On<long, bool, bool>("binaryDeviceUpdated", (deviceId, success, binarySetting) => InvokeDeviceUpdated(deviceId, success, binarySetting: binarySetting));
                _hubProxy.On<long, bool, double>("continousDeviceUpdated", (deviceId, success, continousSetting) => InvokeDeviceUpdated(deviceId, success, continousSetting));

                await _hubConnection.Start();

                await _hubProxy.Invoke("helloMsg", "mobile device here");

                Debug.WriteLine($"{nameof(RealTimeService)}.{nameof(OpenConnection)} SignalR connection opened");
            }
            catch (Exception e)
            {
                Debug.WriteLine($"{nameof(RealTimeService)}.{nameof(OpenConnection)} ex: {e.GetType()}, msg: {e.Message}");
            }
        }
开发者ID:rwojcik,项目名称:imsClient,代码行数:25,代码来源:RealTimeService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IILGen类代码示例发布时间:2022-05-24
下一篇:
C# IHubIncomingInvokerContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap