Example #1
0
        private void sendDataModeRadioButton_Click(object sender, RoutedEventArgs e)
        {
            RadioButton rb = sender as RadioButton;

            if (rb != null)
            {
                switch (rb.Tag.ToString())
                {
                case "char":
                    sendMode = SendMode.Character;
                    Information("提示:发送字符文本。");
                    // 将文本框中内容转换成char
                    sendDataTextBox.Text = Utilities.ToSpecifiedText(sendDataTextBox.Text, SendMode.Character, serialPort.Encoding);
                    break;

                case "hex":
                    // 将文本框中的内容转换成hex
                    sendMode = SendMode.Hex;
                    Information("提示:发送十六进制。输入十六进制数据之间用空格隔开,如:1D 2A 38。");
                    sendDataTextBox.Text = Utilities.ToSpecifiedText(sendDataTextBox.Text, SendMode.Hex, serialPort.Encoding);
                    break;

                default:
                    break;
                }
            }
        }
        /// <summary>
        /// 读取消息发送模式,如果不加默认为Both
        /// </summary>
        static string GenerateProtocolMessage(Type type)
        {
            string content = "";

            SendMode mode = GetSendMode(type);

            if (mode == SendMode.ToClient)
            {
                content += "message m_" + GenerateProtocolName(type) + "_c\n";
                content += GenerateProtocolMessageNoHead(type);
            }
            else if (mode == SendMode.ToServer)
            {
                content += "message m_" + GenerateProtocolName(type) + "_s\n";
                content += GenerateProtocolMessageNoHead(type);
            }
            else
            {
                content += "message m_" + GenerateProtocolName(type) + "_s\n";
                content += GenerateProtocolMessageNoHead(type);

                content += "message m_" + GenerateProtocolName(type) + "_c\n";
                content += GenerateProtocolMessageNoHead(type);
            }

            return(content);
        }
        /// <param name="uri">Splunk server uri, for example https://localhost:8088.</param>
        /// <param name="token">HTTP event collector authorization token.</param>
        /// <param name="metadata">Logger metadata.</param>
        /// <param name="sendMode">Send mode of the events.</param>
        /// <param name="batchInterval">Batch interval in milliseconds.</param>
        /// <param name="batchSizeBytes">Batch max size.</param>
        /// <param name="batchSizeCount">Max number of individual events in batch.</param>
        /// <param name="ignoreSslErrors">Server validation callback should always return true</param>
        /// <param name="middleware">
        /// HTTP client middleware. This allows to plug an HttpClient handler that
        /// intercepts logging HTTP traffic.
        /// </param>
        /// <param name="formatter"></param>
        /// <remarks>
        /// Zero values for the batching params mean that batching is off.
        /// </remarks>
        public HttpEventCollectorSender(
            Uri uri, string token, HttpEventCollectorEventInfo.Metadata metadata,
            SendMode sendMode,
            int batchInterval, int batchSizeBytes, int batchSizeCount, bool ignoreSslErrors,
            HttpEventCollectorMiddleware middleware,
            HttpEventCollectorFormatter formatter = null)
        {
            this.httpEventCollectorEndpointUri = new Uri(uri, HttpEventCollectorPath);
            this.jsonSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            this.jsonSerializerSettings.Formatting            = Formatting.None;
            this.jsonSerializerSettings.Converters            = new[] { new Newtonsoft.Json.Converters.StringEnumConverter() };
            this.jsonSerializer = JsonSerializer.CreateDefault(this.jsonSerializerSettings);
            this.sendMode       = sendMode;
            this.batchInterval  = batchInterval;
            this.batchSizeBytes = batchSizeBytes;
            this.batchSizeCount = batchSizeCount;
            this.metadata       = metadata;
            this.token          = token;
            this.middleware     = middleware;
            this.formatter      = formatter;

            // special case - if batch interval is specified without size and count
            // they are set to "infinity", i.e., batch may have any size
            if (this.batchInterval > 0 && this.batchSizeBytes == 0 && this.batchSizeCount == 0)
            {
                this.batchSizeBytes = this.batchSizeCount = int.MaxValue;
            }

            // when size configuration setting is missing it's treated as "infinity",
            // i.e., any value is accepted.
            if (this.batchSizeCount == 0 && this.batchSizeBytes > 0)
            {
                this.batchSizeCount = int.MaxValue;
            }
            else if (this.batchSizeBytes == 0 && this.batchSizeCount > 0)
            {
                this.batchSizeBytes = int.MaxValue;
            }

            // setup the timer
            if (batchInterval != 0) // 0 means - no timer
            {
                timer = new Timer(OnTimer, null, batchInterval, batchInterval);
            }

            // setup HTTP client
            try
            {
                var httpMessageHandler = ignoreSslErrors ? BuildHttpMessageHandler(ignoreSslErrors) : null;
                httpClient = httpMessageHandler != null ? new HttpClient(httpMessageHandler) : new HttpClient();
            }
            catch
            {
                // Fallback on PlatformNotSupported and other funny exceptions
                httpClient = new HttpClient();
            }

            httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue(AuthorizationHeaderScheme, token);
        }
Example #4
0
        public static void Paste(SendMode mode = SendMode.Input)
        {
            var mods = KeyHandler.DisableModifiers();

            Input.Send("[^][v]", mode);
            KeyHandler.EnableModifiers(mods);
        }
Example #5
0
        public void RequestStart(SendMode mode)
        {
            SetInterrupt();
            fadeOut     = false;
            loopCounter = 0;

            Mode = mode;//orではない

            dataSender.Init();

            if ((mode & SendMode.MML) == SendMode.MML)
            {
                dataMaker.RequestStart();
                while (!dataMaker.IsRunning())
                {
                    //Application.DoEvents();
                }
            }

            dataSender.RequestStart();
            while (!dataSender.IsRunning())
            {
                Application.DoEvents();
            }

            emuChipSender.RequestStart();
            realChipSender.RequestStart();

            ResetInterrupt();
        }
Example #6
0
        public static string ToSpecifiedText(string text, SendMode mode, Encoding encoding)
        {
            string result = "";

            switch (mode)
            {
            case SendMode.Character:
                result = text
                         .SplitWithoutEmpty()                       //分割字符串
                         .Select(item => Convert.ToByte(item, 16))  //转换为byte
                         .ToArray()
                         .GetString(encoding);
                break;

            case SendMode.Hex:
                result = encoding
                         .GetBytes(text.ToArray())
                         .Select(item => item.ToString("X")) // 转换为16进制
                         .Join();                            // 连接字符串
                break;

            default:
                break;
            }

            return(result.Trim());
        }
Example #7
0
        private static void PrepareResponse(HttpContext context, SendMode mode, string fileName, string mimeType, long lengthFile)
        {
            var response = context.Response;

            response.Clear();
            response.Buffer       = false;
            response.CacheControl = "no-cache";
            response.ContentType  = mimeType;

            var preparedFileName = fileName;

            if (context.Request.GetBrowserType() == BrowserType.IE)
            {
                preparedFileName = HttpUtility.UrlEncode(preparedFileName);
                if (preparedFileName != null)
                {
                    preparedFileName = preparedFileName.Replace(@"+", @"%20");
                }
            }
            var contentDisposition = string.Format("{0}; filename=\"{1}\";",
                                                   (mode == SendMode.Attachment) ? "attachment" : "inline",
                                                   preparedFileName
                                                   );

            response.AddHeader("Content-Disposition", contentDisposition);

            response.AddHeader("Content-length", lengthFile.ToString());
        }
Example #8
0
 public void SendMessageToClientsInLOR(Message message, SendMode sendMode)
 {
     foreach (var playerClient in players)
     {
         playerClient.SendMessage(message, sendMode);
     }
 }
Example #9
0
        /// <summary>
        ///     Callback for when data is received.
        /// </summary>
        /// <param name="buffer">The data recevied.</param>
        /// <param name="sendMode">The SendMode used to send the data.</param>
        private void MessageReceivedHandler(MessageBuffer buffer, SendMode sendMode)
        {
            using (Message message = Message.Create(buffer, true))
            {
                //Record any ping acknowledgements
                if (message.IsPingAcknowledgementMessage)
                {
                    try
                    {
                        RoundTripTime.RecordInboundPing(message.PingCode);
                    }
                    catch (KeyNotFoundException)
                    {
                        //Nothing we can really do about this
                    }
                }

                if (message.IsCommandMessage)
                {
                    HandleCommand(message);
                }
                else
                {
                    HandleMessage(message, sendMode);
                }
            }
        }
Example #10
0
        /// <summary>Send text while ignoring modifiers, only affects special [] input</summary>
        public static void Send(string text, SendMode mode = SendMode.Input)
        {
            var mods = KeyHandler.DisableModifiers();

            Input.Send(text, mode);
            KeyHandler.EnableModifiers(mods);
        }
Example #11
0
            ///<summary>Initialize the sender helper for the given PatComms and appointments.</summary>
            ///<param name="clinicNum">The clinic that is doing the sending.</param>
            ///<param name="dtSlotStart">The date time of the time slot for which this list is being sent.</param>
            ///<param name="dtStartSend">The date time when the list should be sent out. This time will be adjusted if necessary.</param>
            internal AsapListSender(SendMode sendMode, List <PatComm> listPatComms, long clinicNum, DateTime dtSlotStart,
                                    DateTime dtStartSend)
            {
                _sendMode         = sendMode;
                _dictPatComms     = listPatComms.GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => x.First());
                _dictPatDetails   = listPatComms.GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => new PatientDetail(x.First()));
                _dictPatAsapComms = GetForPats(listPatComms.Select(x => x.PatNum).ToList()).GroupBy(x => x.PatNum).ToDictionary(x => x.Key, x => x.ToList());
                TimeSpan timeAutoCommStart = PrefC.GetDateT(PrefName.AutomaticCommunicationTimeStart).TimeOfDay;
                TimeSpan timeAutoCommEnd   = PrefC.GetDateT(PrefName.AutomaticCommunicationTimeEnd).TimeOfDay;

                DtSendEmail     = dtStartSend;          //All emails will be sent immediately.
                DtStartSendText = dtStartSend;
                if (PrefC.DoRestrictAutoSendWindow)
                {
                    //If the time to start sending is before the automatic send window, set the time to start to the beginning of the send window.
                    if (DtStartSendText.TimeOfDay < timeAutoCommStart)
                    {
                        DtStartSendText     = DtStartSendText.Date.Add(timeAutoCommStart);
                        IsOutsideSendWindow = true;
                    }
                    else if (DtStartSendText.TimeOfDay > timeAutoCommEnd)
                    {
                        //If the time to start sending is after the automatic send window, set the time to start to the beginning of the send window the next day.
                        DtStartSendText     = DtStartSendText.Date.AddDays(1).Add(timeAutoCommStart);
                        IsOutsideSendWindow = true;
                    }
                }
                string maxTextsPrefVal = ClinicPrefs.GetPrefValue(PrefName.WebSchedAsapTextLimit, clinicNum);

                _maxTextsPerDay = String.IsNullOrWhiteSpace(maxTextsPrefVal) ? int.MaxValue : PIn.Int(maxTextsPrefVal);               //The pref may be set to blank to have no limit
                DtTextSendEnd   = DtStartSendText.Date.Add(timeAutoCommEnd);
                _dtSlotStart    = dtSlotStart;
                SetMinutesBetweenTexts(dtSlotStart);
                ListAsapComms = new List <AsapComm>();
            }
Example #12
0
 public void SendToClient(ushort id, Tags t, IDarkRiftSerializable obj, SendMode mode = SendMode.Reliable)
 {
     using (Message m = Message.Create <IDarkRiftSerializable>((ushort)t, obj))
     {
         ConnectedClients[id].Client.SendMessage(m, mode);
     }
 }
Example #13
0
 public void SendToAll(Message message, SendMode sendMode)
 {
     foreach (var client in Players.Keys)
     {
         client?.SendMessage(message, sendMode);
     }
 }
Example #14
0
 public SendDataType(byte[] buf, string ip, CommunicationMode comMode, SendMode sendMode)
 {
     this.buf      = buf;
     this.ip       = ip;
     this.comMode  = comMode;
     this.sendMode = sendMode;
 }
Example #15
0
    //Initializing Send Mode.
    public void setSendMode(int mode)
    {
        sendMode = (SendMode)mode;
        PlayerPrefs.SetInt("SendMode", mode);

        //Bluetooth specific
        //bluetoothPanel.SetActive(sendMode == SendMode.BLUETOOTH);

        //UDP Specific
        //udpPanel.SetActive(sendMode == SendMode.UDP);
        //if(sendMode != SendMode.UDP) { udpSender.stopSenderThread(); }

        //Agora Specific
        agoraPanel.SetActive(sendMode == SendMode.AGORA);
        if (sendMode != SendMode.AGORA)
        {
            agora.leave();
        }

        //Misty specific
        mistyPanel.SetActive(sendMode == SendMode.MISTY);

        //Misty or UDP
        ipPanel.SetActive(/*sendMode == SendMode.UDP ||*/ sendMode == SendMode.MISTY || sendMode == SendMode.HTTP);
    }
        public HttpEventCollectorSender(
            Uri uri,
            string token,
            HttpEventCollectorEventInfo.Metadata metadata,
            SendMode sendMode,
            int batchInterval,
            int batchSizeBytes,
            int batchSizeCount,
            HttpEventCollectorMiddleware middleware,
            HttpEventCollectorFormatter formatter = null,
            bool ignoreCertificateErrors          = false
            )
        {
            this.httpEventCollectorEndpointUri = new Uri(uri, HttpEventCollectorPath);
            this.sendMode       = sendMode;
            this.batchSizeBytes = batchSizeBytes;
            this.batchSizeCount = batchSizeCount;
            this.metadata       = metadata;
            this.token          = token;
            this.middleware     = middleware;
            this.formatter      = formatter;

            if (batchInterval > 0 && this.batchSizeBytes == 0 && this.batchSizeCount == 0)
            {
                this.batchSizeBytes = this.batchSizeCount = int.MaxValue;
            }
            if (this.batchSizeCount == 0 && this.batchSizeBytes > 0)
            {
                this.batchSizeCount = int.MaxValue;
            }
            else if (this.batchSizeBytes == 0 && this.batchSizeCount > 0)
            {
                this.batchSizeBytes = int.MaxValue;
            }
            if (batchInterval != 0)
            {
                timer = new Timer(OnTimer, null, batchInterval, batchInterval);
            }

            if (ignoreCertificateErrors)
            {
                var certificateHandler = new HttpClientHandler
                {
                    ClientCertificateOptions = ClientCertificateOption.Manual,
                    ServerCertificateCustomValidationCallback =
                        (httpRequestMessage, cert, cetChain, policyErrors) => true
                };
                httpClient = new HttpClient(certificateHandler, true);
            }
            else
            {
                httpClient = new HttpClient();
            }

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
                AuthorizationHeaderScheme,
                token
                );
        }
        public static Tuple <uint, SendMode> GetDataResponseLengthAndSendMode(uint dataResponseLengthAndSendMode)
        {
            uint     dataResponseLength  = dataResponseLengthAndSendMode & DataResponseLengthMask;
            SendMode sendMode            = (SendMode)(dataResponseLengthAndSendMode >> SendModeShift);
            Tuple <uint, SendMode> tuple = new Tuple <uint, SendMode>(dataResponseLength, sendMode);

            return(tuple);
        }
Example #18
0
 public ReceivedMessage(string message, ushort source, ushort destination, ushort tag, SendMode sendMode)
 {
     this.Message     = message;
     this.Source      = source;
     this.Destination = destination;
     this.Tag         = tag;
     this.SendMode    = sendMode;
 }
Example #19
0
        public void RequestStart(SendMode mode, bool useEmu, bool useReal)
        {
            SetInterrupt();
            fadeOut     = false;
            loopCounter = 0;

            Mode = mode;//orではない

            dataSender.Init();

            if ((mode & SendMode.MML) == SendMode.MML)
            {
                if (dataMaker.unmount)
                {
                    dataMaker.Mount();
                }
                while (!dataMaker.IsRunning())
                {
                    dataMaker.RequestStart();
                    Application.DoEvents();
                }
            }

            int timeout = 2000;

            while (!dataSender.IsRunning() && timeout > 0)
            {
                dataSender.RequestStart();
                Application.DoEvents();
                System.Threading.Thread.Sleep(1);
                timeout--;
            }
            if (timeout < 1)
            {
                throw new Exception("dataSender freeze");
            }

            if (useEmu)
            {
                emuChipSender.RequestStart();
            }
            if (useReal)
            {
                realChipSender.RequestStart();
            }

            ResetInterrupt();

            isVirtualOnlySend = false;
            if (setting.other.PlayDeviceCB)
            {
                if (useEmu && !useReal)
                {
                    isVirtualOnlySend = true;
                    //Audio.stopDataVirtulaOnlySend = dataSender.stopData;
                }
            }
        }
Example #20
0
        private void sendPortsData(byte[] buf, string ip, CommunicationMode comMode, SendMode sendMode)
        {
            SendDataType sType = new SendDataType(buf, ip, comMode, sendMode);

            if (cdInterface != null)
            {
                new Thread(sendPortsDataThread).Start(sType);                     // serPort.commWriteByte(buf, 0, buf.Length);
            }
        }
Example #21
0
        /// <summary>
        ///     Sends a message to the server.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <param name="sendMode">How the message should be sent.</param>
        /// <returns>Whether the send was successful.</returns>
        public bool SendMessage(Message message, SendMode sendMode)
        {
            if (message.IsPingMessage)
            {
                RoundTripTime.RecordOutboundPing(message.PingCode);
            }

            return(Connection.SendMessage(message.ToBuffer(), sendMode));
        }
Example #22
0
 public void SetReply(long statusId, string screenName)
 {
     replyStatusId   = statusId;
     TweetBox.Text   = "@" + screenName + " ";
     SendButton.Text = "返神" + (140 - TweetBox.TextLength).ToString();
     sendMode        = SendMode.Reply;
     TweetBox.Focus();
     TweetBox.Select(TweetBox.Text.Length, 0);
 }
Example #23
0
 /// <summary>
 /// Prepares the response.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="lengthFile">The length file.</param>
 public static void PrepareResponse(this HttpContext context, SendMode mode, string fileName, long lengthFile)
 {
     PrepareResponse(
         context,
         mode,
         fileName,
         Mime.GetMimeType(fileName),
         lengthFile);
 }
    public void HandleEnetMessageReceived(Event netEvent, SendMode mode)
    {
        MessageBuffer message = MessageBuffer.Create(netEvent.Packet.Length);

        netEvent.Packet.CopyTo(message.Buffer);
        message.Offset = 0;
        message.Count  = netEvent.Packet.Length;
        HandleMessageReceived(message, SendMode.Reliable);
    }
Example #25
0
        public void SendSerialized(SendMode sendMode, object data, NetClient reciever)
        {
            var result = SerializeData(data, reciever);

            if (result.ShouldSend)
            {
                Manager.SendRaw(sendMode, result.Data, this, reciever);
            }
        }
Example #26
0
 /// <summary>
 /// Sends the file.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fileContent">Content of the file.</param>
 /// <returns></returns>
 public static void SendFile(this HttpContext context, SendMode mode, string fileName, byte[] fileContent)
 {
     PrepareResponse(context,
                     mode,
                     fileName,
                     fileContent.Length);
     context.Response.OutputStream.Write(fileContent, 0, fileContent.Length);
     ResponseEnd(context.Response);
 }
Example #27
0
        public static string ConvertSendModeToString(SendMode mode)
        {
            if (mode == SendMode.OneToOne)
            {
                return("one-to-one");
            }

            return("one-to-many");
        }
    private void HandleEnetMessageReceived(Event netEvent, SendMode mode)
    {
        MessageBuffer message = MessageBuffer.Create(netEvent.Packet.Length);

        netEvent.Packet.CopyTo(message.Buffer);
        message.Offset = 0;
        message.Count  = netEvent.Packet.Length;
        HandleMessageReceived(message, mode);
        message.Dispose();
    }
Example #29
0
 public void SendToAll(Tags t, IDarkRiftSerializable obj, SendMode mode = SendMode.Reliable)
 {
     foreach (KeyValuePair <ushort, ConnectedClient> connectedClient in ConnectedClients)
     {
         using (Message m = Message.Create <IDarkRiftSerializable>((ushort)t, obj))
         {
             connectedClient.Value.Client.SendMessage(m, mode);
         }
     }
 }
Example #30
0
        public static string ResolveSendMode(SendMode mode)
        {
            switch (mode) {
                case SendMode.Input:
                    return "SendInput ";
                case SendMode.Event:
                    return "SendEvent ";
            }

            return DefaultSendMode;
        }
        /// <summary>
        ///     Sends a message to the server.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <param name="sendMode">How the message should be sent.</param>
        /// <returns>Whether the send was successful.</returns>
        public bool SendMessage(Message message, SendMode sendMode)
        {
            bool success = connection?.SendMessage(message.ToBuffer(), sendMode) ?? false;

            if (success)
            {
                messagesSentCounter.Increment();
            }

            return(success);
        }
Example #32
0
    void RpcRunFunction(string sendGameObjectName, string methodName, SendMode mode)
    {
        if(mode == SendMode.OnlyClients && isServer){
            return;
        }

        GameObject _refGObj = GameObject.Find(sendGameObjectName);

        if(_refGObj != null){
            _refGObj.SendMessage(methodName);
        }
    }
Example #33
0
        public static string ToSpecifiedText(string text, SendMode mode, Encoding encoding)
        {
            string result = "";
            switch (mode)
            {
                case SendMode.Character:
                    text = text.Trim();

                    // 转换成字节
                    List<byte> src = new List<byte>();

                    string[] grp = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var item in grp)
                    {
                        src.Add(Convert.ToByte(item, 16));
                    }

                    // 转换成字符串
                    result = encoding.GetString(src.ToArray<byte>());
                    break;
                    
                case SendMode.Hex:
                    
                    byte[] byteStr = encoding.GetBytes(text.ToCharArray());

                    foreach (var item in byteStr)
                    {
                        result += Convert.ToString(item, 16).ToUpper() + " ";
                    }
                    break;
                default:
                    break;
            }

            return result.Trim();
        }
Example #34
0
        // SendKeyWithMod <<<<< TODO: HANDLE DOUBLE MODIFIER (CTRL+ALT+X) >>>>>
        //        - Really cheesy and basically just hopes the caller has a valid keymod and key;
        public static void SendKeyWithMod(Interactor intr, string keyModIn, string keyIn, SendMode sendMode)
        {
            var modeStr = ResolveSendMode(sendMode);

            string keyModStr;
            string keyStr;
            if (!TryParseKeyMod(intr, keyIn, out keyStr, out keyModStr)) {
                keyModStr = keyModIn;
                keyStr = keyIn;
            }

            var keySeq = "{" + keyModStr + " down}{" + keyStr + "}{" + keyModStr + " up}";

            intr.Log(LogEntryType.Trace, "SendKeyWithMod(): Executing: '"+ modeStr + keySeq + "' ...");
            intr.ExecuteStatement(modeStr + keySeq);

            //SendEvent(intr, "{Shift down}{Tab}{Shift up}");

            //var seq = sendModeStr + @" { " + keyMod + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" up }
            //Sleep 60
            //" + sendModeStr + @" { " + keyMod + @" up }
            //Sleep 60
            //";

            //intr.ExecuteStatement(keySeq);
        }
Example #35
0
        private void sendDataModeRadioButton_Click(object sender, RoutedEventArgs e)
        {
            RadioButton rb = sender as RadioButton;

            if (rb != null)
            {
                switch (rb.Tag.ToString())
                {
                    case "char":
                        sendMode = SendMode.Character;
                        Information("提示:发送字符文本。");
                        // 将文本框中内容转换成char
                        sendDataTextBox.Text = Utilities.ToSpecifiedText(sendDataTextBox.Text, SendMode.Character, serialPort.Encoding);
                        break;
                    case "hex":
                        // 将文本框中的内容转换成hex
                        sendMode = SendMode.Hex;
                        Information("提示:发送十六进制。输入十六进制数据之间用空格隔开,如:1D 2A 38。");
                        sendDataTextBox.Text = Utilities.ToSpecifiedText(sendDataTextBox.Text, SendMode.Hex, serialPort.Encoding);
                        break;
                    default:
                        break;
                }
            }
        }
Example #36
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="content"></param>
        /// <param name="mode">one-to-many / one-to-one</param>
        /// <param name="callback"></param>
        private void SendText(string content, SendMode mode, LinccerContentCallback callback)
        {
            // create a plain message
            Hoc hoc = new Hoc();
            hoc.DataList.Add(
                new HocData { Content = content, Type = "text/plain" }
            );

            // share it 1:1, in the Hoccer mobile App, you need to perform a drag in
            // gesture to receive the message  (one-to-many is throw/catch)
            var stringMode = SendModeString.ConvertSendModeToString(mode);
            this._linccer.Share(stringMode, hoc, callback);
        }
Example #37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="mode">one-to-many / one-to-one</param>
        /// <param name="callback"></param>
        private void SendData(byte[] data, SendMode mode, LinccerContentCallback callback)
        {
            // inialize filecache for temporary up- and downloading large files
            var cache = new FileCache();
            cache.Config = this._config;

            cache.Store(data, TIMEOUT, (uri) =>
            {
                Hoc hoc = new Hoc();
                hoc.DataList.Add(
                    new HocData { Uri = uri }
                );

                var stringMode = SendModeString.ConvertSendModeToString(mode);
                // share it 1:1, in the Hoccer mobile App, you need to perform a drag in
                // gesture to receive the message  (one-to-many is throw/catch)
                this._linccer.Share(stringMode, hoc, callback);
            });
        }
Example #38
0
        private void Receive(SendMode mode, LinccerContentCallback contentCallback, FileCacheGetCallback fileCallback)
        {
            var stringMode = SendModeString.ConvertSendModeToString(mode);
            // receive 1:1, in the Hoccer mobile App, you need to perform a drag out
            // gesture to send something to this client (one-to-many is throw/catch)
            this._linccer.Receive<Hoc>(stringMode, (hoc) =>
            {
                if (hoc == null)
                {
                    contentCallback(null);
                }
                else
                {
                    if(hoc.DataList.Any(x => x.Type == "text/plain"))
                    {
                        contentCallback(String.Join(",", hoc.DataList.Where(x => x.Type == "text/plain").Select(x => x.Content)));
                        return;
                    }

                    var data = hoc.DataList.FirstOrDefault(x => x.Uri != string.Empty);

                    //// inialize filecache for temporary up- and downloading large files
                    var cache = new FileCache();
                    cache.Config = this._config;
                    cache.Fetch(data.Uri, fileCallback);
                }
            });
        }
        /// <param name="uri">Splunk server uri, for example https://localhost:8089.</param>
        /// <param name="token">HTTP event collector authorization token.</param>
        /// <param name="metadata">Logger metadata.</param>
        /// <param name="sendMode">Send mode of the events.</param>
        /// <param name="batchInterval">Batch interval in milliseconds.</param>
        /// <param name="batchSizeBytes">Batch max size.</param>
        /// <param name="batchSizeCount">MNax number of individual events in batch.</param>
        /// <param name="middleware">
        /// HTTP client middleware. This allows to plug an HttpClient handler that 
        /// intercepts logging HTTP traffic.
        /// </param>
        /// <remarks>
        /// Zero values for the batching params mean that batching is off. 
        /// </remarks>
        public HttpEventCollectorSender(
            Uri uri, string token, HttpEventCollectorEventInfo.Metadata metadata,
            SendMode sendMode,
            int batchInterval, int batchSizeBytes, int batchSizeCount,
            HttpEventCollectorMiddleware middleware)
        {
            this.httpEventCollectorEndpointUri = new Uri(uri, HttpEventCollectorPath);
            this.sendMode = sendMode;
            this.batchInterval = batchInterval;
            this.batchSizeBytes = batchSizeBytes;
            this.batchSizeCount = batchSizeCount;
            this.metadata = metadata;
            this.token = token;
            this.middleware = middleware;

            // special case - if batch interval is specified without size and count
            // they are set to "infinity", i.e., batch may have any size 
            if (this.batchInterval > 0 && this.batchSizeBytes == 0 && this.batchSizeCount == 0)
            {
                this.batchSizeBytes = this.batchSizeCount = int.MaxValue;
            }

            // when size configuration setting is missing it's treated as "infinity",
            // i.e., any value is accepted.
            if (this.batchSizeCount == 0 && this.batchSizeBytes > 0)
            {
                this.batchSizeCount = int.MaxValue;
            }
            else if (this.batchSizeBytes == 0 && this.batchSizeCount > 0)
            {
                this.batchSizeBytes = int.MaxValue;
            }

            // setup the timer
            if (batchInterval != 0) // 0 means - no timer
            {
                timer = new Timer(OnTimer, null, batchInterval, batchInterval);
            }

            // setup HTTP client
            httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue(AuthorizationHeaderScheme, token);
        }
Example #40
0
 public void SendNetMessageWithString(string sendGameObjectName, string methodName, string str, SendMode mode = SendMode.All)
 {
     if(isServer){
         RpcRunFunctionWithString(sendGameObjectName, methodName, str, mode);
     }
 }
Example #41
0
        public static string ConvertSendModeToString(SendMode mode)
        {
            if(mode == SendMode.OneToOne) return "one-to-one";

            return "one-to-many";
        }