Exemplo n.º 1
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();
                }
            }
        }
Exemplo n.º 2
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;
                }
            }
        }