private async void InitAsync() { Source.Clear(); var result = await client.GetAsync <List <City> >(""); if (result != null) { foreach (var item in result) { Source.Add(item); SourceView.Refresh(); } } signalRClient = ResourcesBase.GetSignalClient(); signalRClient.OnAddCity += SignalRClient_OnAddCity; RefreshCompleted?.Invoke(); }
public async void CompleteTask() { var result = await client.GetAsync <List <Port> >(""); if (result != default(List <Port>)) { Source.Clear(); foreach (var item in result) { Source.Add(item); } SourceView.Refresh(); RefreshCompleted?.Invoke(); } signalRClient = ResourcesBase.GetSignalClient(); signalRClient.OnAddPort += SignalRClient_OnAddPort; }
public static async Task InviteMultipleMembersAsync(SignalRClient signalRClient, Guid channelId, Guid memberId) { // Invite member test var inviteMultipleMembersRequest = new InviteMultipleMembersRequest { ChannelId = channelId, InvitedMembersIds = new List <Guid> { memberId }, RequestId = Guid.NewGuid().ToString() }; Console.WriteLine("Inviting members."); await signalRClient.InviteMultipleMembersAsync(inviteMultipleMembersRequest); Console.WriteLine("Members were invited."); Console.WriteLine(); }
private async void Init() { using (var client = new Client("agents")) { var res = await client.GetAsync <List <agent> >("Get"); if (res != null && res.Count > 0) { foreach (var item in res) { Source.Add(item); } } SourceView.Refresh(); } signalRClient = ResourcesBase.GetSignalClient(); signalRClient.OnAddAgent += SignalRClient_OnAddAgent; }
public static async Task UpdateMessageAsync(SignalRClient signalRClient, Guid messageId) { // Update the message called test var updateMessageRequest = new UpdateMessageRequest { MessageId = messageId, Body = Guid.NewGuid() + "test", HtmlContent = Guid.NewGuid() + "test", HtmlEncoded = false, RequestId = Guid.NewGuid().ToString() }; Console.WriteLine("Updating the message"); await signalRClient.UpdateMessageAsync(updateMessageRequest); Console.WriteLine("Message was updated."); Console.WriteLine(); }
public Streaming(string Url) { var sn = SetShNFromConfig().ToList(); sn.Sort((x, y) => x.CompareTo(y)); Values = new Dictionary <string, LPandOB>(); foreach (var s in sn) { Values.Add(s, new LPandOB { ShortName = s }); } client = new SignalRClient(new HubConnection(Url), sn.ToArray()); client.SetOrderBookEventMethod(UpdateOB); client.SetPriceEventMethod(UpdateLP); }
public async Task Step1_ShouldConnectAdminAndUserClients() { _adminSignalRClient = new SignalRClient(_server.BaseAddress.ToString()); var adminToken = await GetJwtTokenAsync("*****@*****.**", "123QWqw!"); await _adminSignalRClient.ConnectAsync(adminToken, _server.CreateHandler()); _adminSignalRClient.ValidationFailed += (errors, requestId) => { throw new Exception($"Errors: {errors}{Environment.NewLine}RequestId: {requestId}"); }; _userSignalRClient = new SignalRClient(_server.BaseAddress.ToString()); var userToken = await GetJwtTokenAsync("*****@*****.**", "123QWqw!"); await _userSignalRClient.ConnectAsync(userToken, _server.CreateHandler()); _userSignalRClient.ValidationFailed += (errors, requestId) => throw new Exception($"Errors: {errors}{Environment.NewLine}RequestId: {requestId}"); }
public static async Task <ChannelSummaryResponse> CreateDirectChannelAsync(SignalRClient client, Guid memberId) { string groupName = Guid.NewGuid() + "test"; // Create a direct channel called test var createDirectChannelRequest = new CreateDirectChannelRequest { MemberId = memberId, RequestId = Guid.NewGuid().ToString(), }; Console.WriteLine("Creating a direct channel."); var createdChannel = await client.CreateDirectChannelAsync(createDirectChannelRequest); Console.WriteLine("Direct channel was created."); Console.WriteLine(); return(createdChannel); }
public static async Task <MessageResponse> AddMessageAsync(SignalRClient signalRClient, Guid channelId) { // Create the message called test var createMessageRequest = new AddMessageRequest { ChannelId = channelId, Body = "test", Type = MessageType.Default, RequestId = Guid.NewGuid().ToString() }; Console.WriteLine("Creating the message"); var createdMessage = await signalRClient.AddMessageAsync(createMessageRequest); Console.WriteLine("Message was created."); Console.WriteLine(); return(createdMessage); }
private static async Task TestSignalR() { try { var options = new SignalRClientOptions("http://localhost:9000") { IsDebug = false }; var client = new SignalRClient(options); using (var connection = await client.Connect(Guid.NewGuid())) { var loginResult = await connection.Login(); } } catch (Exception ex) { Log.Logger.Error(ex, "SignalR client error: {Message}", ex.Message); } }
static void Main(string[] args) { var url = "http://gppdev:4478/signalr"; var hubName = "EventHub"; var eventName = "OnEvent"; var signalRClient = new SignalRClient <object>(url, hubName, eventName); signalRClient.RegisterChannel("SourceIntegration"); signalRClient.RegisterChannel("MessageIntegration"); signalRClient.RegisterChannel("Movimento"); signalRClient.RegisterChannel("Notificacao"); signalRClient.OnEventReceived += SignalRClient_OnEventReceived; signalRClient.OnConnectionSlow += SignalRClient_OnConnectionSlow; signalRClient.OnStart += SignalRClient_OnStart; signalRClient.OnStop += SignalRClient_OnStop; signalRClient.OnError += SignalRClient_OnError; signalRClient.Start(); Console.ReadKey(); }
private static async Task ExecuteMembersManagementLogic(SignalRClient signalRClient, AuthMicroserviceConfiguration authMicroserviceConfiguration) { var userName = authMicroserviceConfiguration.UserName; var invitedUserName = authMicroserviceConfiguration.InvitedUserName; authMicroserviceConfiguration.UserName = invitedUserName; await ConnectAsync(authMicroserviceConfiguration, signalRClient); var client = await HubCommands.GetClientAsync(signalRClient); // switch user authMicroserviceConfiguration.UserName = userName; await ConnectAsync(authMicroserviceConfiguration, signalRClient); var channel = await HubCommands.CreateChannelAsync(signalRClient); await HubCommands.InviteMemberAsync(signalRClient, channel.Id, client.MemberId); await HubCommands.DeleteMemberAsync(signalRClient, channel.Id, client.MemberId); await HubCommands.InviteMultipleMembersAsync(signalRClient, channel.Id, client.MemberId); }
static void Main(string[] args) { var environment = Environment.GetEnvironmentVariable(EnvironmentVariableName); var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true) .Build(); _authMicroserviceConfiguration = GetAuthMicroserviceConfiguration(configuration); _chatMicroserviceConfiguration = GetChatMicroserviceConfiguration(configuration); if (_authMicroserviceConfiguration != null && _chatMicroserviceConfiguration != null) { var signalRClient = new SignalRClient(_chatMicroserviceConfiguration.ChatUrl, GetJwtTokenAsync); var manualResetEventSlim = new ManualResetEventSlim(); var runningClientTask = RunClientAsync(signalRClient, manualResetEventSlim); runningClientTask.Wait(); manualResetEventSlim.Wait(); } }
public static async Task <ChannelSummaryResponse> UpdateChannelAsync(SignalRClient signalRClient, Guid channelId) { // Update the channel called test var updateChannelRequest = new UpdateChannelRequest { ChannelId = channelId, Name = Guid.NewGuid() + "test", Topic = "test", WelcomeMessage = "test", Type = ChannelType.Public, AllowedMembers = new List <Guid>(), RequestId = Guid.NewGuid().ToString(), PhotoUrl = "https://softeqnonamemessaging.blob.core.windows.net/temp/1000_abf08299411.jpg" }; Console.WriteLine("Updating the channel."); var updatedChannel = await signalRClient.UpdateChannelAsync(updateChannelRequest); Console.WriteLine("Channel was updated."); Console.WriteLine(); return(updatedChannel); }
//Типа старт, запускается при выполеном подключении public void StartShooting() { _signalRClient = GetComponent <SignalRClient>(); _hubConnection = _signalRClient.HubConnection; _hubProxy = _signalRClient.HubProxy; _gameHelper = _signalRClient.GameHelper; //подписываемся на рассылку пуль Subscription subscriptionInstantiateBullet = _signalRClient.HubProxy.Subscribe("instantiateBullet"); subscriptionInstantiateBullet.Received += subscription_DataInstantiateBullet => { foreach (var item in subscription_DataInstantiateBullet) { //десериализуем объект в item BulletModel bulletModel = new BulletModel(); bulletModel = JsonConvert.DeserializeObject <BulletModel>(item.ToString()); //добавляем эти объекты в Pool и когда смогу, то Instantiate их в LateUpdate _instantiateBulletPool.Add(bulletModel); } }; //подписываемся на рассылку пуль Subscription subscriptionRegisteredHitBullet = _signalRClient.HubProxy.Subscribe("registeredHitBullet"); subscriptionRegisteredHitBullet.Received += subscription_DataRegisteredHitBullet => { foreach (var item in subscription_DataRegisteredHitBullet) { //десериализуем объект в item HitModel hitModel = JsonConvert.DeserializeObject <HitModel>(item.ToString()); //добавляем в пул на регистрацию попаданий _hitBulletPool.Add(hitModel); } }; }
public static async Task <ChannelSummaryResponse> CreateChannelAsync(SignalRClient client) { string groupName = Guid.NewGuid() + "test"; // Create the channel called test var createChannelRequest = new CreateChannelRequest { Closed = false, Name = groupName, Topic = "test", WelcomeMessage = "test", Type = ChannelType.Public, RequestId = Guid.NewGuid().ToString(), PhotoUrl = "https://softeqnonamemessaging.blob.core.windows.net/temp/1000_abf08299411.jpg" }; Console.WriteLine("Creating the channel."); var createdChannel = await client.CreateChannelAsync(createChannelRequest); Console.WriteLine("Channel was created."); Console.WriteLine(); return(createdChannel); }
static void Main(string[] args) { try { //Create and connect to SignalR client SignalRClient client = new SignalRClient(); client.ConnectToSignalRHub().Wait(); //Subscribe to callback method for notification is sent via SignalR. client.OnDataReceivedCallBack(Datareceived); //Guid buttonGuid = Guid.Parse("Add Guid of button you want to subscribe to."); Guid buttonGuid = Guid.Parse("4d461a00-2124-e611-80c3-000d3a3384f5"); Console.WriteLine($"Subsribing to button: {buttonGuid.ToString()}\n"); //Subscribe to button via its Guid identifier. client.SubscribeToEntity(buttonGuid, ButtonTypeEnum.TwoRockerButton); Console.WriteLine("Currentely subscribed to following buttons:"); //Print out current subscriptions. Should only be one as we have only subscribed to one button at this time. foreach (var item in client.GetCurrentSubsriptions()) { Console.WriteLine("------------------------------------------------------------------------------"); Console.WriteLine($"Button Id : {item.Key}\nButton Type : {item.Value}"); Console.WriteLine("------------------------------------------------------------------------------"); } while (true) { } //Console.WriteLine("\n\nPress enter to exit\n"); //Console.ReadLine(); } catch (Exception ex) { } }
public void RegsiteredCallbackActivatedWhenMatchingHubToClientMsgArrives() { var hubToClientMsg = "{\"C\":\"d-115B33FD-K,0|Z,1|a,0\",\"M\":[{\"H\":\"ActiveQuadsHub\",\"M\":\"ActiveQuads\",\"A\":[[{\"Id\":3,\"QuadId\":\"yy\",\"SupportedComms\":0,\"SupportedIMU\":0,\"SupportGPS\":0,\"SupportedAlt\":0,\"InUse\":false}]]}]}"; var theCallback = Substitute.For<Action<List<ActiveQuad>>>(); var hubMethodTypeMapping = new Dictionary<Type, string>(); var clientMethodTypeMapping = new Dictionary<string, ISignalRMsgParserJson> { { "ActiveQuads", new HubToClientMsgParserJson<List<ActiveQuad>>()} }; var signalRClient = new SignalRClient() { HubMethodTypeMapping = hubMethodTypeMapping, ClientMethodTypeMapping = clientMethodTypeMapping, HubConnectionParams = new HubConnectionParams("ActiveQuadsHub", "myserer", false) }; signalRClient.Register<List<ActiveQuad>>("ActiveQuads",theCallback); signalRClient.MsgRcved(new List<ReceivedSignalRMsg> { new ReceivedSignalRMsg(DateTime.Now, hubToClientMsg) }); theCallback.Received()(Arg.Any<List<ActiveQuad>>()); }
private static async Task RunClientAsync(SignalRClient signalRClient, ManualResetEventSlim wh) { try { while (true) { Console.WriteLine("Choose required option for testing from the list below:"); Console.WriteLine("1 - Channels management"); Console.WriteLine("2 - Messages management"); Console.WriteLine("3 - Members management"); Console.WriteLine("0 - Close"); bool isParsed = int.TryParse(Console.ReadLine(), out int choiceNumber); if (isParsed) { await HandleChoiceNumberAsync(choiceNumber, signalRClient); } else { Console.WriteLine("Error. Choose a valid digit!"); } if (isParsed && choiceNumber == 0) { break; } } } catch (Exception ex) { Console.WriteLine("Error: " + ex.GetBaseException().Message); } finally { wh.Set(); } }
/// <summary> /// Use this for initialization /// </summary> void Start() { signalRClient = GameObject.Find("SignalRClient").GetComponent <SignalRClient>(); }
public ValuesController(SignalRClient signalRClient, OrleansClient orleansClient) { _signalRClient = signalRClient; _orleansClient = orleansClient; }
private static async Task ConnectAsync(AuthMicroserviceConfiguration authMicroserviceConfiguration, SignalRClient client) { var token = await GetJwtTokenAsync(authMicroserviceConfiguration.Password, authMicroserviceConfiguration.UserName, authMicroserviceConfiguration.AuthUrl); await client.ConnectAsync(token); Console.WriteLine("Logged on successfully."); Console.WriteLine(); }
public static void HandleInput(SignalRClient signalRClient) { while (true) { var input = Console.ReadLine(); var output = ""; if (String.IsNullOrEmpty(input)) { output = signalRClient.Connection.State.ToString(); } if (input.ToLower().StartsWith("addtogroup")) { var param = input.GetParameter(); signalRClient.AddToSignalRGroup(param); } if (input.ToLower().StartsWith("createlobby")) { //var param = input.GetParameter(); var lobbyId = HttpClients.Post(); if (!String.IsNullOrEmpty(lobbyId)) { output = $"Created Lobby. Id: {lobbyId}"; signalRClient.AddToSignalRGroup(lobbyId); } else { output = "Failed To Create Lobby"; } } if (input.ToLower().StartsWith("signalrcreatelobby")) { //var param = input.GetParameter(); signalRClient.CreateLobby(); //if (!String.IsNullOrEmpty(lobbyId)) //{ // output = $"Created Lobby. Id: {lobbyId}"; // signalRClient.AddToSignalRGroup(lobbyId); //} //else output = "Failed To Create Lobby"; } if (input.ToLower().StartsWith("signalrdeletelobby")) { var param = input.GetParameter(); //if (!String.IsNullOrEmpty(lobbyId)) //{ // output = $"Created Lobby. Id: {lobbyId}"; signalRClient.DeleteLobby(new Guid(param)); //} //else output = "Failed To Create Lobby"; } if (input.ToLower().StartsWith("deletelobby")) { var param = input.GetParameter(); var success = HttpClients.Delete(new Guid(param)); if (success) { output = "Successfully Deleted Lobby"; } else { output = "Failed to Delete Lobby"; } } Console.WriteLine(output); } }
/// <summary> /// Initializes a new instance of the <see cref="MainPageViewModel"/> class. /// </summary> public MainPageViewModel() { slideValue = 0; signalR = new SignalRClient(); signalR.ValueChanged += SignalR_ValueChanged; }
static void Main(string[] args) { //connector = new SQLiteConnector(@"C:\Users\Brd\Desktop\IOT-Flow-Control\Shared\Data.db"); // TODO : Cambiare db -> mysql connector = new MySQLConnector("192.168.178.20", "dbIOTFC", "admin", "errata"); //Da portare su file esterno var broker = new MQTTBroker(); broker.StartServer(UID, PWD, Port); var client = new MQTTClient(); client.StartClient(UID, PWD, "MASTER"); var dBServices = new DBServices(connector); var signalr = new SignalRClient("localhost", 5000, "hubs/notifyhub"); signalr.RaiseException = true; //signalr.SendMessage("UpdateCompany", new { Company = 1 }); var actionprovider = new MQTTActionProvider() .AddEndpointAction("esp/get_anagra", endpointdata => { var device = dBServices.getDevice(endpointdata.ID); var location = dBServices.getDeviceLocation(device.ID_Device); if (location.HasValue) { var anagra = dBServices.getLocationInfo(location.Value); client.SendMessage("brokr/" + endpointdata.ID + "/anagra", JsonConvert.SerializeObject(anagra)); } else { client.SendMessage("brokr/" + endpointdata.ID + "/anagra", JsonConvert.SerializeObject(new { ID_Location = -2 })); } }) .AddEndpointAction("esp/put_delta", endpointdata => { var device = dBServices.getDevice(endpointdata.ID); var location = dBServices.getDeviceLocation(device.ID_Device); //Controllo se ha una location valida if (location.HasValue) { dynamic doc = JsonConvert.DeserializeObject(endpointdata.Payload); var value = (int)doc.not_synced_delta; dBServices.logDeviceDelta(device.ID_Device, value); signalr.SendMessage(null, new { Company = location.Value }); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Thread.Sleep(2000); Console.WriteLine("Delta changed on company : " + location.Value + ". Saving..."); Thread.Sleep(200); Console.WriteLine("Added " + value + " to location " + location.Value); client.SendMessage("brokr/" + endpointdata.ID + "/reset_delta", ""); Console.WriteLine(); Console.Write("Sending delta reset to device " + device.Mac_Address + "..."); Thread.Sleep(300); Console.Write("OK"); } }) .AddEndpointAction("esp/get_pcount", endpointdata => { var device = dBServices.getDevice(endpointdata.ID); var location = dBServices.getDeviceLocation(device.ID_Device); if (location.HasValue) { var anagra = dBServices.getLocationInfo(location.Value); if (anagra != null) { //client.SendMessage("brokr/" + endpointdata.ID + "/pcount", JsonConvert.SerializeObject(new { People_Count = anagra.People_Count })); //Informo il sender con la nuova conta //! Da aggiungere la logica per chiamare tutti i dispositivi associati a quella location ! } } }); broker.OnSubscribe += sub => dBServices.RegisterDevice(sub); broker.OnReceive += x => actionprovider.Run(x); //Rispondo alla richiesta ricevuta dal broker Console.WriteLine("Server in ascolto sulla porta {0},premere un INVIO per uscire...", Port); Console.ReadLine(); // broker.ClientSubscribed += sub => // { // var device = dBServices.getDevice(sub.ID); // if (device.Registered_Location.HasValue) // { // var location = dBServices.getLocationInfo(device.Registered_Location.Value); // string serialize = JsonSerializer.Serialize(new // { // ID_Location = device.Registered_Location.Value, // People_Count = location.People_Count, // Business_Name = location.Business_Name, // Address = location.Address, // PostalCode = location.PostalCode, // City = location.City // }; // } // else // { // string serialize = JsonSerializer.Serialize(new // { // ID_Location = -2 // }); // } // }; }
// コンストラクタ public TalkPageViewModel(INavigationService navigationService, ITalkManager talkManager, Setting setting, SignalRClient signalRClient) : base(navigationService) { _talkManager = talkManager; _setting = setting; _signalRClient = signalRClient; _signalRClient.ValueChanged += SignalR_ValueChanged; Talks = _talkManager.ToReactivePropertyAsSynchronized(x => x.Talks); }
/// <summary> /// Inits the signal r. /// </summary> /// <returns>The signal r.</returns> /// <param name="accessToken">Access token.</param> public async Task InitSignalR(string accessToken) { _signalRClient = new SignalRClient(); await _signalRClient.Connect(accessToken); }
public static Task Logout(this SignalRClient client, UserData userData, string whoAreYou) { return(client.InvokeService <UserData>(BEConstant.User.SERVICE_CODE, BEConstant.User.LOGOUT_METHOD, userData, whoAreYou)); }
//Standard is the name of this method equals the name of the original method in Signalr.Service public static Task Login(this SignalRClient client, UserData userData, string whoAreYou) { //(Service, Method, Arguments to be used, Query String) return(client.InvokeService <UserData>(BEConstant.User.SERVICE_CODE, BEConstant.User.LOGIN_METHOD, userData, whoAreYou)); }
public static Task Subscribe(this SignalRClient client, string groupName) { return(client.InvokeService <string>(BEConstant.HubLog.SERVICE_CODE, BEConstant.HubLog.LOG_METHOD, groupName, BEConstant.HubLog.HUB_LOG)); }
private void button2_Click(object sender, EventArgs e) { _Client = new SignalRClient(); _Client.InitHub("", "ServerHubBase"); _Client.StartConnect(); }