static void Main(string[] args) { var conn = new XSockets.Client40.XSocketClient("ws://hackzurich.cloudapp.net:8080", "http://localhost", "sensor"); conn.QueryString.Add("sensortype", "photon"); conn.OnConnected += (e, i) => { Console.WriteLine("Connected"); }; var sensor = conn.Controller("sensor"); sensor.On("ready", () => { while (true) { var d = new SensorData() { Humidity = 2.334, Temperature = 23.000, }; sensor.Invoke("wd", d); System.Threading.Thread.Sleep(5000); } }); sensor.OnOpen += (a, b) => { var d = new SensorClientData() { Lat = 47.367347, Lng = 8.5500025, Name = "Demo", Organization = "XSockets", SensorId = conn.PersistentId.ToString() }; sensor.Invoke("ci", d); System.Threading.Thread.Sleep(3000); }; //monitor.OnOpen += (e, i) => { // Console.WriteLine("Monitor Controller Opened"); //}; //monitor.On<SensorClientData>("wd", (data) => { // Console.WriteLine("Id: {0}",data.SensorId); // Console.WriteLine("Org: {0}", data.Organization); // Console.WriteLine("Name: {0}", data.Name); // Console.WriteLine("Tmp: {0}", data.Temperature); // Console.WriteLine("Hum: {0}", data.Humidity); // Console.WriteLine("Lat: {0}", data.Lat); // Console.WriteLine("Lng: {0}", data.Lng); //}); conn.Open(); Console.ReadLine(); }
void initConnection() { Task.Delay(2000); var client = new XSockets.Client40.XSocketClient("ws://localhost:4502", "http://localhost", "geocars"); client.Controller("geocars").On<GeoCar>("pos", d => { ReceivedGeoCarEvent(d.Id, new Location() { Latitude = d.GeoData.Lat, Longitude = d.GeoData.Lng }); }); client.Open(); }
/// <summary> /// Initializes a new instance of the MainWindow class /// </summary> public MainWindow() { xsocketClient = new XSockets.Client40.XSocketClient(connstring, "http://localhost", controllers); xsocketClient.SetAutoReconnect(); xsocketClient.QueryString.Add("clienttype", "kinect"); xsocketClient.Open(); // only one sensor is currently supported this.kinectSensor = KinectSensor.GetDefault(); // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); // set the BodyFramedArrived event notifier this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // initialize the BodyViewer object for displaying tracked bodies in the UI this.kinectBodyView = new KinectBodyView(this.kinectSensor); // initialize the gesture detection objects for our gestures this.gestureDetectorList = new List<GestureDetector>(); // initialize the MainWindow this.InitializeComponent(); // set our data context objects for display in UI this.DataContext = this; this.kinectBodyViewbox.DataContext = this.kinectBodyView; // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI int col0Row = 0; int col1Row = 0; int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount; for (int i = 0; i < maxBodies; ++i) { GestureResultView result = new GestureResultView(i, false, false, 0.0f); GestureDetector detector = new GestureDetector(this.kinectSensor, result); this.gestureDetectorList.Add(detector); // split gesture results across the first two columns of the content grid ContentControl contentControl = new ContentControl(); contentControl.Content = this.gestureDetectorList[i].GestureResultView; if (i % 2 == 0) { // Gesture results for bodies: 0, 2, 4 Grid.SetColumn(contentControl, 0); Grid.SetRow(contentControl, col0Row); ++col0Row; } else { // Gesture results for bodies: 1, 3, 5 Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, col1Row); ++col1Row; } this.contentGrid.Children.Add(contentControl); } }