Пример #1
0
        private void SendMessage(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter)
            {
                string spokenMessage = "";

                spokenMessage = TxtSend.Text;

                if (!string.IsNullOrEmpty(spokenMessage))
                {
                    // Send the recognition result text as a Realtime message
                    Message message = new Message();
                    message.id     = myID;
                    message.text   = spokenMessage;
                    message.sentAt = DateTime.Now.ToLocalTime().ToString("HH:mm");

                    string jsonMessage = JsonConvert.SerializeObject(message);
                    Debug.WriteLine("Sending message: " + jsonMessage);
                    ortcClient.Send(chatcode, jsonMessage);
                    TxtSend.Text = "";

                    MyScrollViewer.UpdateLayout();
                    MyScrollViewer.ChangeView(0.0f, double.MaxValue, 1.0f);
                    //MyScrollViewer.ScrollToVerticalOffset(MyScrollViewer.ScrollableHeight);
                }
            }
        }
Пример #2
0
        public void SendTrackerLocation(string userName, Position location)
        {
            if (!string.IsNullOrEmpty(GameId))
            {
                throw new Exception("Not subscribed to a game. Call Join game");
            }
            var message = GetMessage(userName, location);

            ortcClient.Send(GameId, message);
        }
Пример #3
0
        private void DrawCircle()
        {
            double precision = 0.06;
            double radious = 70;
            double x, y;

            for (double i = 0; i < 2 * Math.PI; i += precision)
            {
                x = Math.Cos(i) * radious;
                y = Math.Sin(i) * radious;

                int ix = 150 + Convert.ToInt32(x);
                int iy = 150 + Convert.ToInt32(y);

                string message = "{ \"left\": \"" + ix + "\", \"top\": \"" + iy + "\" }";

                Log("Send:" + message + " to " + txtClientChannel.Text);

                _ortc.Send(txtClientChannel.Text, message);
            }
        }
Пример #4
0
        /// <summary>
        /// Actually broadcasts the data
        /// </summary>
        private void SendData(object sender, EventArgs e)
        {
            Log("Getting data from FSX"); // Log

            // Gets the data from FS
            FsLongitude lon = new FsLongitude(playerLongitude.Value);
            FsLatitude  lat = new FsLatitude(playerLatitude.Value);

            FSUIPCConnection.Process();               // Process the request to FSUIPC
            FSUIPCConnection.Process("AircraftInfo"); // For aicraft type

            // Checks if we have data
            if (lat.DecimalDegrees != 0 || lon.DecimalDegrees != 0)
            {
                // This will help us force the period as our decimal separator
                NumberFormatInfo nfi = new NumberFormatInfo();
                nfi.NumberDecimalSeparator = ".";
                nfi.NumberGroupSeparator   = ",";

                // Let's fill our player data object
                PlayerData playerData = new PlayerData();
                playerData.id     = "Whatever"; // Set your own ID here v
                playerData.lon    = lon.DecimalDegrees.ToString(nfi);
                playerData.lat    = lat.DecimalDegrees.ToString(nfi);
                playerData.ias    = (int)((double)airspeed.Value / 128d);                                   // Aircraft speed (KIAS)
                playerData.hdg    = (int)((double)(playerHeadingTrue.Value - magVar.Value) * 8.3819E-008d); // Heading
                playerData.alt    = (int)(playerAltitude.Value * 3.28084 / (65536d * 65536d));              // Altitude (feet)
                playerData.type   = aircraftType.Value.ToString();                                          // // our icon will depend on the engine type. For simplicity sake, we're assuming helicopter are always type 3
                playerData.icon   = (int)engineType.Value == 3 ? "heli" : "fixed";                          // Engine type. Helicopters are usually type 3 but there are some exceptions (like the default Robinson)
                playerData.pitch  = (int)(playerPitch.Value * 8.3819E-008d);
                playerData.bank   = (int)(playerBank.Value * 8.3819E-008d);
                playerData.altMb  = (int)(playerAltimeterPressure.Value * 16);
                playerData.vertAs = (int)(playerVertSpeed.Value * 60 * 3.28084 / 256);

                // And serialize it
                string data = Newtonsoft.Json.JsonConvert.SerializeObject(playerData);

                Log(string.Format("Sending data to ORTC: {0}", data)); // Log
                ortcClient.Send(txtORTCChannel.Text, data);            // Sends the data to ORTC
            }
        }
Пример #5
0
        /// <summary>
        /// Sends the fugitive location.
        /// </summary>
        /// <returns><c>true</c>, if fugitive location was sent, <c>false</c> otherwise.</returns>
        /// <param name="message">Message.</param>
        public bool SendHello(HelloMessage message)
        {
            EnsureUsername(message);

            if (client.IsConnected && client.IsSubscribed(Channel))
            {
                string data = System.Web.HttpUtility.UrlEncode(JsonConvert.SerializeObject(message));
                client.Send(Channel, data);
            }
            else
            {
                throw new Exception("not connected. Call Join Game first");
            }
            return(true);
        }
Пример #6
0
 public void DoSendMessage(String message2)
 {
     ortcClient.Send(Channel, message2);
 }
Пример #7
0
 public void DoSendMessage(object sender, RoutedEventArgs e)
 {
     ortcClient.Send(Channel, Message);
 }
 public void DoSend(object s, EventArgs e)
 {
     //DoSendChunk();
     client.Send(Channel, Message);
 }
Пример #9
0
        void Send()
        {  // Parallel Task: Send
            Log("Send:" + Message + " to " + Channel);

            _ortc.Send(Channel, Message);
        }