public void ExitRoom(CS_ExitRoom cs, string connectionId) { try { var host = _host.Find(r => r.PrivateIp == cs.PrivateIp && r.Port == cs.Port && r.GameName == cs.GameName); if (host == null) { HubModel sc = new HubModel() { Code = 104, Msg = "ExitRoom Fail", }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } host.Player--; } catch (Exception ex) { HubModel error = new HubModel() { Code = 103, Msg = "EnterRoom Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public void GetRoomList(CS_RoomList cs, string connectionId) { try { SC_RoomList sc = new SC_RoomList() { Code = 1, RoomList = new List <SC_Room>(), }; for (int i = 0; i < _host.Count; i++) { if (_host[i].State == RoomState.Wait && _host[i].GameName == cs.GameName) { sc.RoomList.Add(new SC_Room() { PrivateIp = _host[i].PrivateIp, Port = _host[i].Port, Player = _host[i].Player, }); } } HubConnector.Client(connectionId).GetRoomList(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 102, Msg = "GetRoomList Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
protected NetworkManagerBase(NetworkConfig networkConfig, EcdsaKeyPair keyPair, byte[] hubPrivateKey, int version, int minPeerVersion) { if (networkConfig.Peers is null) { throw new ArgumentNullException(); } _messageFactory = new MessageFactory(keyPair); LocalNode = new Node { Version = 0, Timestamp = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds(), PublicKey = keyPair.PublicKey, Nonce = (uint)new Random().Next(1 << 30), BlockHeight = 0, Agent = "Lachain-v0.0-dev" }; _hubConnector = new HubConnector( string.Join(",", networkConfig.BootstrapAddresses), hubPrivateKey, networkConfig.NetworkName ?? "devnet", version, minPeerVersion, networkConfig.NewChainId ?? throw new Exception("No newChainId in config"), networkConfig.HubMetricsPort ?? 7072, _messageFactory, networkConfig.HubLogLevel ); _hubConnector.OnMessage += _HandleMessage; _broadcaster = new ClientWorker(new byte[33], _messageFactory, _hubConnector); _broadcaster.Start(); }
public void StartGame(CS_StartGame cs, string connectionId) { try { SC_StartGame sc = new SC_StartGame() { Code = 1 }; var host = _host.Find(r => r.GameName == cs.GameName && r.ConnectionId == connectionId); if (host == null) { sc.Code = 105; sc.Msg = "StartGame Fail"; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } host.State = RoomState.Play; HubConnector.Client(connectionId).StartGame(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 105, Msg = "StartGame Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public Page1() { InitializeComponent(); connector = new HubConnector("http://localhost:5000/notifications"); connector.Connect(); connector.MessageReceived += Connector_MessageReceived; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// MainWindowViewModel constructor /// </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// public MainWindowViewModel() { HubConnector.StartConnection(); HubConnector.MyConnector.startRecordingEvent += MyConnector_startRecordingEvent; HubConnector.MyConnector.stopRecordingEvent += MyConnector_stopRecordingEvent; mdmanager.NewMqttTextReceived += IUpdateTextBox; setlhdes.SetDescriptions(); Application.Current.MainWindow.Closing += MainWindow_Closing; }
public void GetAddress(string connectionId) { try { string address = _accessor.HttpContext.Connection.RemoteIpAddress.ToString(); HubConnector.Client(connectionId).GetAddress(JsonConvert.SerializeObject(address)); } catch (Exception ex) { } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> MainWindowViewModel constructor . </summary> /// /// <remarks> Jordi Hutjens, 30-10-2018. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// public MainWindowViewModel() { CheckLearningHub(); if (CheckParameters.Instance.LHRunning) { HubConnector.StartConnection(); HubConnector.MyConnector.startRecordingEvent += MyConnector_startRecordingEvent; HubConnector.MyConnector.stopRecordingEvent += MyConnector_stopRecordingEvent; setlhdes.SetDescriptions(); } udpmanager.NewUdpTextReceived += IUpdateTextBox; Application.Current.MainWindow.Closing += MainWindow_Closing; }
public void CreateRoom(CS_CreateRoom cs, string connectionId) { try { SC_CreateRoom sc = new SC_CreateRoom() { Code = 1, }; Room room = _host.Find(r => r.PrivateIp == cs.PrivateIp && r.Port == cs.Port); if (room != null) { sc.Code = 101; sc.Msg = "CreateRoom Fail. Ip & Port are already using"; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } Room data = new Room() { ConnectionId = connectionId, PrivateIp = cs.PrivateIp, Port = cs.Port, State = RoomState.Wait, GameName = cs.GameName, Player = 1, }; _host.Add(data); User user = new User() { ConnectionId = connectionId, RoonNum = _host.Count - 1, }; _user.Add(user); HubConnector.Client(connectionId).ResponseCreateRoom(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 101, Msg = "CreateRoom Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public void SendTagDataToLH(TagCreatedEventArgs tag) { try { var values = new List <string> { tag.Tag.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void SendGsrDataToLH(GSRSensorChangedEventArgs gsr) { try { var values = new List <string> { gsr.GalvanicSkinResponse.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void SendBvpDataToLH(BVPSensorChangedEventArgs bvp) { try { var values = new List <string> { bvp.BloodVolumePulse.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void SendTmpDataToLH(TemperatureSensorChangedEventArgs tmp) { try { var values = new List <string> { tmp.SkinTemperature.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void SendIbiDataToLH(IBISensorChangedEventArgs ibi) { try { var values = new List <string> { ibi.InterBeatInterval.ToString(), ibi.HearthRateVariability.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private async Task InitializeHubConnector() { hubConnector = new HubConnector(); hubConnector.TTSResponseDelegate += HubConnector_TTSResponseDelegate; hubConnector.StartAsync(); await Task.Delay(500); CurrentSpeech = "We invite you to experience the future of AI that will empower your employees with disabilities to pick a warehouse order and inspire your team."; Conversations.Add(new Conversation { IsAI = true, Message = CurrentSpeech }); hubConnector.GetText2Speech("XamarinDemoApp", CurrentSpeech); CurrentSpeech = "Are you ready to start picking?"; lastAIText = CurrentSpeech; hubConnector.GetText2Speech("XamarinDemoApp", CurrentSpeech); }
/// <summary>Sends a data to lh.</summary> /// /// <remarks>Jordi Hutjens, 9-11-2018.</remarks> /// /// <param name="acc">Accelerometer changed event information.</param> public void SendAccDataToLH(AccelerometerChangedEventArgs acc) { try { var values = new List <string> { acc.AccelerometerX.ToString(), acc.AccelerometerY.ToString(), acc.AccelerometerZ.ToString() }; HubConnector.SendData(values); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
/// <summary>MainWindowViewModel constructor.</summary> /// /// <remarks>Jordi Hutjens, 10-11-2018.</remarks> public MainWindowViewModel() { CheckLearningHub(); if (CheckParameters.Instance.LHRunning) { HubConnector.StartConnection(); HubConnector.MyConnector.StartRecordingEvent += MyConnector_startRecordingEvent; HubConnector.MyConnector.StopRecordingEvent += MyConnector_stopRecordingEvent; } CheckParameters.Instance.CheckStartupParameters(); if (CheckParameters.Instance.LHRunning) { lhjson.SetValueNames(); } SubscribeToEvents(); IAppereance(); bleserver.CheckBLEServer(); synctcp.ConnectEmpatica(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Sets the descriptions. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetDescriptions() { var names = new List <string> { "ESP_TimeStap", "IMU1_AccX", "IMU1_AccY", "IMU1_AccZ", "IMU1_GyroX", "IMU1_GyroY", "IMU1_GyroZ", "IMU1_MagX", "IMU1_MagY", "IMU1_MagZ", "IMU1_Q0", "IMU1_Q1", "IMU1_Q2", "IMU1_Q3", "IMU2_AccX", "IMU2_AccY", "IMU2_AccZ", "IMU2_GyroX", "IMU2_GyroY", "IMU2_GyroZ", "IMU2_MagX", "IMU2_MagY", "IMU2_MagZ", "IMU2_Q0", "IMU2_Q1", "IMU2_Q2", "IMU2_Q3", "Temp_Ext", "Humidity_Ext", "Temp_Int", "Humidity_Int", "Pulse_TempLobe", "GSR" }; HubConnector.SetValuesName(names); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Sends the published sensor data to the Learning Hub. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> /// /// <param name="e"> Parameter containing the filtered Json string data. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SendDataToLH(TextReceivedEventArgs e) { var values = new List <string> { e.ESPTimeStamp, e.IMU1_AccX, e.IMU1_AccY, e.IMU1_AccZ, e.IMU1_GyroX, e.IMU1_GyroY, e.IMU1_GyroZ, e.IMU1_MagX, e.IMU1_MagY, e.IMU1_MagZ, e.IMU1_Q0, e.IMU1_Q1, e.IMU1_Q2, e.IMU1_Q3, e.IMU2_AccX, e.IMU2_AccY, e.IMU2_AccZ, e.IMU2_GyroX, e.IMU2_GyroY, e.IMU2_GyroZ, e.IMU2_MagX, e.IMU2_MagY, e.IMU2_MagZ, e.IMU2_Q0, e.IMU2_Q1, e.IMU2_Q2, e.IMU2_Q3, e.TempExternal, e.HumExternal, e.TempInternal, e.HumInternal, e.Pulse, e.GSR }; HubConnector.SendData(values); }
public void OnDisconnected(string connectionId) { try { Room host = _host.Find(r => r.ConnectionId == connectionId); if (host != null) { _host.Remove(host); } } catch (Exception ex) { HubModel error = new HubModel() { Code = 2, Msg = "Disconnect Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
/// <summary> Sets value names. </summary> /// /// <remarks> Jordi Hutjens, 8-11-2018. </remarks> public void SetValueNames() { try { List <string> names = new List <string>(); if (CheckParameters.Instance.DataStream == "acc") { names.Add("Empatica_AccX"); names.Add("Empatica_AccY"); names.Add("Empatica_AccZ"); } if (CheckParameters.Instance.DataStream == "tmp") { names.Add("Empatica_Temp"); } if (CheckParameters.Instance.DataStream == "bvp") { names.Add("Empatica_Bvp"); } if (CheckParameters.Instance.DataStream == "ibi") { names.Add("Empatica_Ibi"); names.Add("Empatica_Hrv"); } if (CheckParameters.Instance.DataStream == "tag") { names.Add("Empatica_Tag"); } if (CheckParameters.Instance.DataStream == "gsr") { names.Add("Empatica_Gsr"); } HubConnector.SetValuesName(names); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }