public void InvokeOnMessageBinary(byte[] data, string bag)
        {
            BwwBag msg = JsonSerializer.Deserialize <BwwBag>(bag);

            msg.binarydata = data;


            BwwMessage b = new BwwMessage
            {
                ID            = GetNewIDFromLog(),
                Date          = DateTime.Now,
                MessageType   = BwwMessageType.received,
                TransportType = BwwTransportType.Binary,
                WwBag         = msg
            };

            if (DoLog)
            {
                Log.Add(b);

                if (Log.Count > LogMaxCount)
                {
                    Log.RemoveAt(0);
                }
            }


            OnMessage?.Invoke(b);
        }
        public void InvokeOnMessage(string par_message)
        {
            BwwBag msg = JsonSerializer.Deserialize <BwwBag>(par_message);

            BwwMessage b = new BwwMessage
            {
                ID            = GetNewIDFromLog(),
                Date          = DateTime.Now,
                MessageType   = BwwMessageType.received,
                TransportType = BwwTransportType.Text,
                WwBag         = msg,
            };


            if (DoLog)
            {
                Log.Add(b);

                if (Log.Count > LogMaxCount)
                {
                    Log.RemoveAt(0);
                }
            }

            OnMessage?.Invoke(b);
        }
Example #3
0
        public void WwOnMessage(BwwMessage par_message)
        {
            BwwBag b = par_message.WwBag;

            if (par_message.TransportType == BwwTransportType.Text)
            {
                if ((BResultType)b.Cmd == BResultType.ActualMessage)
                {
                    SwwWs_Item i = new SwwWs_Item
                    {
                        GUID     = Guid.NewGuid().ToString(),
                        Date     = DateTime.Now,
                        Caption  = b.data,
                        ClientID = b.ClientID,
                    };

                    log_list.Insert(0, i);

                    StateHasChanged();
                }
            }
            else
            {
                if ((BResultType)b.Cmd == BResultType.ActualMessage)
                {
                    SwwWs_Item i = new SwwWs_Item
                    {
                        GUID     = Guid.NewGuid().ToString(),
                        Date     = DateTime.Now,
                        Caption  = Encoding.UTF8.GetString(b.binarydata) + " [" + string.Join(", ", b.binarydata) + "]",
                        ClientID = b.ClientID,
                    };

                    log_list.Insert(0, i);

                    StateHasChanged();
                }
            }
        }
Example #4
0
        public void WwOnMessage(BwwMessage par_message)
        {
            BwwBag b = par_message.WwBag;

            if (par_message.TransportType == BwwTransportType.Text)
            {
                BResultType r = (BResultType)b.Cmd;
                switch (r)
                {
                case BResultType.ActualMessage:
                    SwwWs_Item i = new SwwWs_Item
                    {
                        GUID     = Guid.NewGuid().ToString(),
                        Date     = DateTime.Now,
                        Caption  = b.data,
                        ClientID = b.ClientID,
                    };

                    log_list.Insert(0, i);

                    BlazorWindowHelper.BlazorTimeAnalyzer.Log();
                    StateHasChanged();
                    break;

                case BResultType.StateChange:
                    BwwState s = ((BwwState)short.Parse(b.data));
                    if (s == BwwState.Close)
                    {
                        WwClose();
                    }
                    else
                    {
                        Ws_Status = s.ToString();
                        WebWorkerHelper1.Ws_List.Single(x => x.bWebSocketID == WebWorkerHelper1.Active_WebSocket_ID).state = s;
                    }



                    StateHasChanged();
                    break;

                case BResultType.MultyPurposeItem1:
                    WsCreateInternal(b.data);
                    break;

                default:
                    break;
                }
            }
            else
            {
                BResultType r = (BResultType)b.Cmd;
                switch (r)
                {
                case BResultType.ActualMessage:
                    SwwWs_Item i = new SwwWs_Item
                    {
                        GUID     = Guid.NewGuid().ToString(),
                        Date     = DateTime.Now,
                        Caption  = Encoding.UTF8.GetString(b.binarydata) + " [" + string.Join(", ", b.binarydata.Take(100)) + "]",
                        ClientID = b.ClientID,
                    };

                    log_list.Insert(0, i);
                    BlazorWindowHelper.BlazorTimeAnalyzer.Log();
                    StateHasChanged();
                    break;

                case BResultType.StateChange:
                    WebWorkerHelper1.Ws_List.Single(x => x.bWebSocketID == WebWorkerHelper1.Active_WebSocket_ID).state = (BwwState)short.Parse(b.data);
                    break;

                default:
                    break;
                }
            }
        }
Example #5
0
 public void WwOnMessage(BwwMessage par_message)
 {
     StateHasChanged();
 }