Exemple #1
0
        // Invio del messaggio
        public async Task <IActionResult> OnPostMessage()
        {
            if (ModelState.IsValid)
            {
                var serviceClient = ServiceClient.CreateFromConnectionString(
                    _configuration.GetConnectionString("connectionString"),
                    TransportType.Amqp);
                var temp = new MessageMap();

                temp.DeviceId    = Input.DeviceId;
                temp.TextColorId = Input.TextColorId;
                temp.Text        = Input.Text;


                var json = JsonConvert.SerializeObject(temp);

                var text    = System.Text.UTF8Encoding.UTF8.GetBytes(Input.Text);
                var message = new Message(text);

                await serviceClient.SendAsync(Input.DeviceId, message);

                Message = $"Messaggio inviato al dispositivo {Input.DeviceId} con successo";

                return(RedirectToPage());
            }
            return(Page());
        }
        public MessageMap Build(TEntity order)
        {
            var messageMap = new MessageMap("a");

            _fields.Do(f => f.Build(order)).Run(f => messageMap.AddField(f));
            return(messageMap);
        }
Exemple #3
0
    static int step3(string command, int iNum1, int iNum2)
    {
        MessageMap[] aMessageMap = new MessageMap[] {
            new MessageMap()
            {
                cmd = "더하기", Method = add
            },
            new MessageMap()
            {
                cmd = "빼기", Method = sub
            },
            new MessageMap()
            {
                cmd = "곱하기", Method = mul
            },
            new MessageMap()
            {
                cmd = "나누기", Method = div
            }
        };

        foreach (MessageMap Temp in aMessageMap)
        {
            if (Temp.cmd.Equals(command))
            {
                return(Temp.Method(iNum1, iNum2));
            }
        }

        return(0);
    }
Exemple #4
0
        public bool ConvertPostableMessageTo16(ref Win32.MSG msg32, out Win16.MSG msg16)
        {
            // Setup basic message
            msg16 = new Win16.MSG()
            {
                message = (ushort)msg32.message,
                hWnd    = HWND.Map.To16(msg32.hWnd),
                time    = msg32.time,
                pt      = msg32.p.Convert(),
            };

            // Get message semantics
            var sem = TryGetMessageSemantics32(msg32.hWnd, msg32.message, out msg16.message);

            // If it should be bypassed, just return false
            if (sem != null && sem.ShouldBypass(_machine, ref msg32))
            {
                return(false);
            }

            // Postable message?
            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                postable.To16(_machine, ref msg32, ref msg16);
                return(true);
            }

            MessageMap.ThrowMessageError(msg32.hWnd, msg32.message);
            return(false);
        }
Exemple #5
0
        // Postable messages are any message that don't contain pointers and can be fully
        // represented by wParam and lParam

        public bool ConvertPostableMessageTo32(ref Win16.MSG msg16, out Win32.MSG msg32)
        {
            // Setup basic message
            msg32 = new Win32.MSG()
            {
                hWnd    = HWND.Map.To32(msg16.hWnd),
                message = (ushort)msg16.message,
                time    = msg16.time,
                p       = msg16.pt.Convert(),
            };

            // Get message semantics
            var sem = TryGetMessageSemantics16(msg32.hWnd, msg16.message, out msg32.message);

            // Postable message?
            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                postable.To32(_machine, ref msg16, ref msg32);
                return(true);
            }

            MessageMap.ThrowMessageError(msg32.hWnd, msg32.message);
            return(false);
        }
Exemple #6
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var chats = GetChannels().Result;

                    foreach (var o in chats)
                    {
                        Console.WriteLine($"ChannelId : {o.Id}, Title : {o.Title}, AccessHash : {o.AccessHash}, UserName : {o.Username}");

                        if (o.Left)
                        {
                            continue;
                        }

                        /*// TODO : 테스트가 끝나면 지워야함
                         * if (o.Title == "Team IU" )
                         * {
                         *  continue;
                         * }*/


                        if (o.Title == ForwardChannelName)
                        {
                            ForwardChannelId         = o.Id;
                            ForwardChannelAccessHash = o.AccessHash.Value;
                            isReadyForward           = true;
                            continue;
                        }

                        if (!MessageMap.ContainsKey(o.Id))
                        {
                            MessageMap.Add(o.Id, 0);
                        }


                        if (isReadyForward)
                        {
                            var messages = GetMessages(o.Id, o.AccessHash.Value, 10).Result;
                            Forwarder.Instance.Send(messages, MessageMap, o, MessageCheckMap).Wait();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Message : {ex.Message} \nStackTrace : {ex.StackTrace}");
                }

                Thread.Sleep(2000);
            }
        }
Exemple #7
0
    // 异步收包线程.
    private void waitSocket()
    {
        Debug.Log("receiver");
        int len;

        while (true)
        {
            if (!clientSocket.Poll(-1, SelectMode.SelectRead))
            {
                Debug.Log("poll error");
                Close();
            }

            len = clientSocket.Receive(buf.GetRaw(), 0, HEAD_SIZE,
                                       SocketFlags.None);

            if (len < 0)
            {
                Debug.Log("length error");
                Close();
                return;
            }

            Debug.Assert(len == HEAD_SIZE);
            int payload_length = buf.GetInt(0);

            Debug.Assert(payload_length < BUFF_SIZE);
            int         want   = payload_length;
            int         lenAll = 0;
            SocketError socketError;

            while (want > 0)
            {
                len = clientSocket.Receive(buf.GetRaw(), lenAll, want,
                                           SocketFlags.None, out socketError);
                want   -= len;
                lenAll += len;
            }



            Debug.Log("receive length:" + lenAll + " payload_length:" + payload_length);

            Debug.Assert(payload_length == lenAll);
            var ms2 = new MemoryStream(buf.GetRaw(), 0, payload_length);

            var protoPacket = ProtoBuf.Serializer.Deserialize <packet>(ms2);
            Debug.Log("receive packet.cmd:" + protoPacket.cmd);
            var eventname = MessageMap.GetEventName(protoPacket.cmd);
            Event.FireOut(eventname, new object[] { protoPacket.payload });
        }
    }
Exemple #8
0
        public uint CallWndProc32from16(Win32.WNDPROC pfnProc, ushort hWnd, ushort message16, ushort wParam, uint lParam)
        {
            if (message16 == Win16.WM_WIN3MU_BYPASS16)
            {
                var bpm = RetrieveBypassMessage(lParam);
                bpm.retVal = pfnProc(HWND.Map.To32(hWnd), bpm.message, bpm.wParam, bpm.lParam);
                return(0);
            }

            uint message32;
            var  sem = TryGetMessageSemantics16(HWND.Map.To32(hWnd), message16, out message32);

            var msg32 = new Win32.MSG()
            {
                hWnd    = HWND.Map.To32(hWnd),
                message = message32,
            };

            var msg16 = new Win16.MSG()
            {
                hWnd    = hWnd,
                message = message16,
                wParam  = wParam,
                lParam  = lParam,
            };

            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                // Convert it
                postable.To32(_machine, ref msg16, ref msg32);

                // Call it
                return((uint)pfnProc(msg32.hWnd, msg32.message, msg32.wParam, msg32.lParam));
            }

            // Callable?
            var callable = sem as MessageSemantics.Callable;

            if (callable != null)
            {
                return(callable.Call32from16(_machine, false, false, ref msg16, ref msg32, () =>
                {
                    return pfnProc(msg32.hWnd, msg32.message, msg32.wParam, msg32.lParam);
                }));
            }

            // Unsupported
            MessageMap.ThrowMessageError(HWND.Map.To32(hWnd), message16);
            return(0);
        }
Exemple #9
0
        public void Convert32to16(ref Win32.MSG msg32, Action <Win16.MSG> callback)
        {
            if (_machine.IsStoppedInDebugger)
            {
                return;
            }

            ushort message16;
            var    sem = TryGetMessageSemantics32(msg32.hWnd, msg32.message, out message16);

            var msg16 = new Win16.MSG()
            {
                hWnd    = HWND.Map.To16(msg32.hWnd),
                message = message16,
            };


            if (sem != null && sem.ShouldBypass(_machine, ref msg32))
            {
                return;
            }

            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                // Convert it
                postable.To16(_machine, ref msg32, ref msg16);
                callback(msg16);
                return;
            }

            // Callable?
            var callable = sem as MessageSemantics.Callable;

            if (callable != null)
            {
                callable.Call16from32(_machine, true, false, ref msg32, ref msg16, () =>
                {
                    callback(msg16);
                    return(0);
                });
                return;
            }

            MessageMap.ThrowMessageError(msg32.hWnd, msg32.message);
            throw new NotImplementedException();
        }
        public ActionResult MessagingPage(int id = 0)
        {
            int ownID = (int)Session["userID"];

            if (id != 0 && id != ownID)
            {
                if (_messageMapService.GetMap(ownID, id) == null)
                {
                    _messageMapService.Add(new MessageMap {
                        FromAccountID = ownID, LastMessageDate = DateTime.Now, ToAccountID = id
                    });
                    MessageMap targetMessageMap = _messageMapService.GetMap(id, ownID);

                    if (targetMessageMap == null)
                    {
                        _messageMapService.Add(new MessageMap {
                            FromAccountID = id, LastMessageDate = DateTime.Now, ToAccountID = ownID
                        });
                    }
                }
            }

            List <MessagePageData> messageMaps = _messageMapService.GetMessages(ownID);

            int[] indexOfDeletedMaps = new int[0];

            for (int i = 0; i < messageMaps.Count; i++)
            {
                int otherAccountID = messageMaps[i].AccountID;
                if (messageMaps.Where(x => x.AccountID == otherAccountID).ToList().Count > 1 && messageMaps[i].FromAccountID == ownID)
                {
                    Array.Resize(ref indexOfDeletedMaps, indexOfDeletedMaps.Length + 1);
                    indexOfDeletedMaps[indexOfDeletedMaps.Length - 1] = i;
                }
            }

            Array.Sort(indexOfDeletedMaps);
            for (int i = indexOfDeletedMaps.Length - 1; i > -1; i--)
            {
                messageMaps.Remove(messageMaps[indexOfDeletedMaps[i]]);
            }

            return(View(new MessagePageViewModel {
                AccountsOfMessages = messageMaps.OrderByDescending(x => x.LastMessageDate).ToList(), MainAccountID = (int)Session["userID"]
            }));
        }
Exemple #11
0
    static int step4(string command, int iNum1, int iNum2)
    {
        MessageMap[] aMessageMap = new MessageMap[] {
            new MessageMap("더하기", add),
            new MessageMap("빼기", sub),
            new MessageMap("곱하기", mul),
            new MessageMap("나누기", div)
        };

        foreach (MessageMap Temp in aMessageMap)
        {
            if (Temp.cmd.Equals(command))
            {
                return(Temp.Method(iNum1, iNum2));
            }
        }

        return(0);
    }
Exemple #12
0
        public void Convert16to32(ref Win16.MSG msg16, Action <Win32.MSG> callback)
        {
            if (msg16.message == Win16.WM_WIN3MU_BYPASS16)
            {
                return;
            }

            var msg32 = new Win32.MSG()
            {
                hWnd = HWND.Map.To32(msg16.hWnd),
            };

            var sem = TryGetMessageSemantics16(msg32.hWnd, msg16.message, out msg32.message);

            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                // Convert it
                postable.To32(_machine, ref msg16, ref msg32);

                // Call it
                callback(msg32);
                return;
            }

            // Callable?
            var callable = sem as MessageSemantics.Callable;

            if (callable != null)
            {
                callable.Call32from16(_machine, false, false, ref msg16, ref msg32, () =>
                {
                    callback(msg32);
                    return(IntPtr.Zero);
                });
                return;
            }

            // Unsupported
            MessageMap.ThrowMessageError(msg32.hWnd, msg16.message);
        }
        /// <summary>
        /// Get messages for a given role name
        /// </summary>
        /// <param name="roleName">Role name as displayed in-game</param>
        /// <returns></returns>
        public IEnumerable <Message> GetMessagesForRole(string roleName)
        {
            string[] messageNames;
            if (!RoleMessageMap.TryGetValue(roleName, out messageNames))
            {
                return(Enumerable.Empty <Message>());
            }

            var messages = new List <Message>();

            foreach (var messageName in messageNames)
            {
                if (!MessageMap.TryGetValue(messageName, out var message))
                {
                    WelcomesMod.Instance.Warn($"Role {roleName} has a message called {messageName} which is invalid");
                    continue;
                }
                messages.Add(message);
            }

            return(messages);
        }
        public ActionResult SendMessage(long id, FormCollection fc)
        {
            string strMessage = fc["Message"];

            try
            {
                Guid userid = _repoUserProfile.GetSingle(x => x.Id == id).UserId;
                EmailSender.SendMail(Membership.GetUser(userid).Email, "Leonni Private Message", strMessage);

                MessageModel objMessage = new MessageModel();
                objMessage.SentDate       = DateTime.Now;
                objMessage.SentBy         = _repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId).Id;
                objMessage.MessageContent = strMessage;
                objMessage.SentTo         = id;
                _repoMessage.Add(MessageMap.Map(objMessage));
                _repoMessage.Save();
                return(Json(new { status = "success", Message = "Message sent" }));
            }
            catch (Exception e)
            {
                return(Json(new { status = "error", Message = "Unable to send Message" }));
            }
        }
        public void SendMessage(string message, int targetID, int ownID)
        {
            MessageMap messageMap = _messageMapService.GetMap(ownID, targetID);

            messageMap.LastMessageDate = DateTime.Now;
            _messageMapService.Update(messageMap);

            MessageMap targetMessageMap = _messageMapService.GetMap(targetID, ownID);

            targetMessageMap.LastMessageDate = DateTime.Now;
            _messageMapService.Update(targetMessageMap);

            _messageService.Add(new Message
            {
                IsActive       = true,
                IsRead         = false,
                MessageContent = message,
                MessageMapID   = messageMap.MessageMapID,
                SendDate       = DateTime.Now
            });

            Clients.All.addMessage(message, targetID, ownID);
        }
 public override void When()
 {
     messageMap = map.Build(order);
 }
Exemple #17
0
        public void Init()
        {
            var chats = GetChannels().Result;

            // 마지막메세지를 전송하지 않기위해 메세지 아이디를 업데이트 함.
            if (Configs.Instance.lastmessage_send == false)
            {
                foreach (var o in chats)
                {
                    if (o.Left)
                    {
                        continue;
                    }

                    if (!MessageMap.ContainsKey(o.Id))
                    {
                        MessageMap.Add(o.Id, 0);
                    }

                    var messages = GetMessages(o.Id, o.AccessHash.Value).Result;
                    foreach (var message in messages)
                    {
                        if (message.Id > MessageMap[o.Id])
                        {
                            MessageMap[o.Id] = message.Id;
                        }
                    }
                }
            }
            else
            {
                foreach (var o in chats)
                {
                    if (o.Left)
                    {
                        continue;
                    }

                    // TODO : 테스트가 끝나면 지워야함
                    if (o.Title == "Team IU")
                    {
                        continue;
                    }


                    if (o.Title == ForwardChannelName)
                    {
                        ForwardChannelId         = o.Id;
                        ForwardChannelAccessHash = o.AccessHash.Value;
                        continue;
                    }


                    if (!MessageMap.ContainsKey(o.Id))
                    {
                        MessageMap.Add(o.Id, 0);
                    }
                }

                foreach (var o in chats)
                {
                    if (o.Left)
                    {
                        continue;
                    }

                    /*  // TODO : 테스트가 끝나면 지워야함
                     * if (o.Title == "Team IU")
                     * {
                     *    continue;
                     * }*/


                    if (o.Title == ForwardChannelName)
                    {
                        ForwardChannelId         = o.Id;
                        ForwardChannelAccessHash = o.AccessHash.Value;
                        continue;
                    }


                    if (!MessageMap.ContainsKey(o.Id))
                    {
                        MessageMap.Add(o.Id, 0);
                    }

                    var messages = GetMessages(o.Id, o.AccessHash.Value, 1).Result;
                    foreach (var message in messages)
                    {
                        Forwarder.Instance.Send(messages, MessageMap, o, MessageCheckMap).Wait();
                    }
                }
            }
        }
Exemple #18
0
        public IntPtr CallWndProc16from32(uint pfnProc, IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam, bool dlgProc)
        {
            // Package it
            var msg32 = new Win32.MSG()
            {
                hWnd    = hWnd,
                message = message,
                wParam  = wParam,
                lParam  = lParam,
            };

            if (_machine.IsStoppedInDebugger)
            {
                if (dlgProc)
                {
                    return(IntPtr.Zero);
                }
                return(User.DefWindowProc(hWnd, message, wParam, lParam));
            }

            // Call filters
            for (int i = 0; i < _wndProcFilters.Count; i++)
            {
                var f    = _wndProcFilters[i];
                var retv = f.PreWndProc(pfnProc, ref msg32, dlgProc);
                if (retv.HasValue)
                {
                    return(retv.Value);
                }
            }

            // Log messages?
            if (_machine.logMessages)
            {
                Log.WriteLine("Message: [{4}] hWnd: {0} message:{1} wParam:{2} lParam:{3}", (HWND)hWnd, MessageNames.NameOfMessage(message), wParam, lParam, User.GetTickCount());
            }

            ushort message16;
            var    sem = TryGetMessageSemantics32(hWnd, message, out message16);

            var msg16 = new Win16.MSG()
            {
                hWnd    = HWND.Map.To16(hWnd),
                message = message16,
            };


            if (sem != null && sem.ShouldBypass(_machine, ref msg32))
            {
                if (dlgProc)
                {
                    return(IntPtr.Zero);
                }

                // Unsupported message - sneak it through
                var bpm = AllocBypassMessage(message, wParam, lParam);
                var ret = _machine.CallWndProc16(pfnProc, HWND.Map.To16(hWnd), Win16.WM_WIN3MU_BYPASS16, 0, bpm.id);
                return(FreeBypassMessage(bpm));
            }

            var postable = sem as MessageSemantics.Postable;

            if (postable != null)
            {
                // Convert it
                postable.To16(_machine, ref msg32, ref msg16);

                // Call it
                var x = _machine.CallWndProc16(pfnProc, msg16.hWnd, msg16.message, msg16.wParam, msg16.lParam);

                if (dlgProc)
                {
                    x = x.Loword();
                }

                return(BitUtils.DWordToIntPtr(x));
            }

            // Callable?
            var callable = sem as MessageSemantics.Callable;

            if (callable != null)
            {
                var x = callable.Call16from32(_machine, false, dlgProc, ref msg32, ref msg16, () =>
                {
                    return(_machine.CallWndProc16(pfnProc, msg16.hWnd, msg16.message, msg16.wParam, msg16.lParam));
                });
                if (dlgProc)
                {
                    x = (IntPtr)(x.ToInt32().Loword());

                    // If not handled by dialog proc and ctlcolor message, switch to white
                    if (x == IntPtr.Zero)
                    {
                        bool recolor = false;
                        switch (message)
                        {
                        case Win32.WM_CTLCOLORDLG:
                        case Win32.WM_CTLCOLORSTATIC:
                        case Win32.WM_CTLCOLORBTN:
                            recolor = true;
                            break;
                        }

                        if (recolor)
                        {
                            Gdi.SetTextColor(wParam, User._GetSysColor(Win32.COLOR_WINDOWTEXT));
                            x = User.GetSysColorBrush(Win32.COLOR_WINDOW);
                        }
                    }
                }
                return(x);
            }

            MessageMap.ThrowMessageError(hWnd, message);
            throw new NotImplementedException();
        }
Exemple #19
0
 public Messenger()
 {
     messageMap = new MessageMap();
 }
Exemple #20
0
    static void Main(string[] args)
    {
        Console.Write("정수1을 입력하세요 : ");
        int iNum1 = Int32.Parse(Console.ReadLine());

        Console.Write("정수2를 입력하세요 : ");
        int iNum2 = Int32.Parse(Console.ReadLine());

        MessageMap[] aMessageMap = new MessageMap[] {
            new MessageMap("더하기", add),
            new MessageMap("빼기", sub),
            new MessageMap("곱하기", mul),
            new MessageMap("나누기", div)
        };
        string command;
        bool   bingo = false;

        while (true)
        {
            Console.Write("수행할 연산을 한글로 입력하세요(도움말 : ?) : ");
            command = Console.ReadLine();


            if (null == command)
            {
                Console.WriteLine("잘 못 입력하셨습니다");
                continue;
            }

            if ('?' == command[0])
            {
                Console.WriteLine("사용할 수 있는 연산 리스트");
                Console.WriteLine("==================================");
                foreach (MessageMap Temp in aMessageMap)
                {
                    Console.WriteLine(Temp.cmd);
                }
                Console.WriteLine("==================================");
                continue;
            }

            foreach (MessageMap Temp in aMessageMap)
            {
                if (Temp.cmd.Equals(command))
                {
                    bingo = true;
                }
            }

            if (false == bingo)
            {
                Console.WriteLine("잘 못 입력하셨습니다");
                continue;
            }

            break;
        }

        int Result = step4(command, iNum1, iNum2);

        Console.WriteLine(command + $"의 결과는 {Result}입니다.");
    }
Exemple #21
0
 public ServiceBus(MessageMap messageMap, IMessageBucket bucket)
 {
     this.messageMap = messageMap;
     this.bucket     = bucket;
     subscribers     = new SubscriberCollection();
 }
Exemple #22
0
 public void Update(MessageMap messageMap)
 {
     _messageMapDal.Update(messageMap);
 }
Exemple #23
0
 public void Add(MessageMap messageMap)
 {
     _messageMapDal.Add(messageMap);
 }
Exemple #24
0
        private static void MessageStuff()
        {
            var config = new RabbitConsumerConfig()
            {
                ExchangeBindings = new List <ExchangeBinding>()
                {
                    new ExchangeBinding
                    {
                        RoutingKey   = "billing.account.create",
                        ExchangeName = "Billing"
                    },
                    new ExchangeBinding
                    {
                        RoutingKey   = "billing.account.delete",
                        ExchangeName = "Billing"
                    },
                    new ExchangeBinding
                    {
                        RoutingKey   = "policy.term.created",
                        ExchangeName = "Policy"
                    }
                },
                QueueName = "PrototypeQueue",
                HostName  = "10.0.0.190",
                UserName  = "******",
                Password  = "******",
                Port      = 5672
            };

            var account = new CreateAccount
            {
                AccountName   = "Account Name",
                Amount        = 10.20m,
                CorrelationId = "1234"
            };

            var deleteAccount = new AccountDelete()
            {
                CorrelationId = "1234",
                AccountId     = 2
            };

            var stringValue = JsonConvert.SerializeObject(deleteAccount);

            var factory = new MessageFactory(MessageMap.GetMessageMap());

            UnityContainer container = new UnityContainer();

            container.RegisterType <IMessageHandler <CreateAccount>, CreateAccountHandler>();

            var handler    = new CreateAccountHandler();
            var badHandler = new DeleteAccountHandler();
            var dispatcher = new MessageDispatcher();

            dispatcher.RegisterHandler(handler);
            dispatcher.RegisterHandler(badHandler);

            dispatcher.Register <CreateAccount>((i) =>
            {
                System.Console.WriteLine($"From Action account Name {i.AccountName}");
            });

            var consumer = new RabbitConsumer(config, factory, dispatcher);

            string value = string.Empty;

            while (value != "exit")
            {
                value = System.Console.ReadLine();
            }

            consumer.Dispose();
        }
Exemple #25
0
 void Start()
 {
     MessageMap.Install();
     _modAgent.RegisterEvent();
 }