Exemplo n.º 1
0
        public String AddMsg(int id, string msg)
        {
            String output;

            HelloMsg theMsg = new HelloMsg();

            theMsg.ID     = id;
            theMsg.MSG    = msg;
            theMsg.STATUS = "working";

            try
            {
                _proxy.Update <HelloMsg>(theMsg,
                                         null,             //no transactions
                                         long.MaxValue, 0, //lease and write timeouts
                                         UpdateModifiers.UpdateOrWrite);

                output = "[" + theMsg.ToString() + "] was written to the space";
            }
            catch (Exception e)
            {
                output = e.Message;
            }
            return(output);
        }
Exemplo n.º 2
0
    public static object Hello(params object[] args)
    {
        HelloMsg msg = new HelloMsg();

        msg.Hello = new Dictionary <string, string>();
        msg.Hello.Add("Name", args[0].ToString());
        return(msg);
    }
Exemplo n.º 3
0
        public ActionResult Show()
        {
            HelloMsg msg = new HelloMsg();

            msg.Display = "Hello";

            return(View(msg));
        }
Exemplo n.º 4
0
        /**
         * topicID - unique ID of the cell in the Excel
         * RTDparms - must have at least one parameter
         * getNewValues - used by the Excel, no need change
         */
        public object ConnectData(int topicID, ref Array RTDparms, ref bool getNewValues)
        {
            // Registering for notifications on status "done"
            HelloMsg notifyTemplate = new HelloMsg();

            notifyTemplate.STATUS = "done";
            _eventReg             = _proxy.DefaultDataEventSession.AddListener
                                    <HelloMsg>(notifyTemplate, Space_DataChanged);

            //store the cell this RTD is written in
            _topicID = topicID;
            return("This cell is listening for msg with status 'done' ...");
        }
Exemplo n.º 5
0
        public void Connect(string ip, int port, string username)
        {
            if (_client != null)
            {
                return;
            }

            _client = new Client(ip, (ushort)port);

            _client.OnClientConnected += (_, _) => _client.SendAsync(HelloMsg.Create(username));
            _client.OnMessage         += MessageHandler;

            _client.ConnectAsync();
        }
Exemplo n.º 6
0
        public String SetToDone(int id)
        {
            String output;

            HelloMsg theMsg = new HelloMsg();

            theMsg.ID     = id;
            theMsg.STATUS = "done";

            try
            {
                _proxy.Update <HelloMsg>(theMsg,
                                         null,             //no transactions
                                         long.MaxValue, 0, //lease and write timeouts
                                         UpdateModifiers.PartialUpdate);
                output = "setting Messgae ID " + id + " to done...";
            }
            catch (Exception e)
            {
                output = e.Message;
            }
            return(output);
        }
Exemplo n.º 7
0
    public static void Main()
    {
        HelloMsg obj = new HelloMsg();

        obj.Write();
    }
Exemplo n.º 8
0
 public static void Main()
 {
     HelloMsg obj = new HelloMsg();
     obj.Write();
 }
Exemplo n.º 9
0
 //private void Destroy(List wh)
 //{
 //    if (wh.chain >= 0)
 //    {
 //        this.gameObject.SetActive(false);
 //        wh.chain--;
 //        EndChain(wh);
 //    }
 //}
 public void Hello(HelloMsg msg)
 {
     switch(msg.pos)
     {
         case "top":
             topn = msg.neighbor;
             topn.change += CheckN;
             break;
         case "bot":
             botn = msg.neighbor;
             botn.change += CheckN;
             break;
         case "left":
             leftn = msg.neighbor;
             leftn.change += CheckN;
             break;
         case "right":
             rightn = msg.neighbor;
             rightn.change += CheckN;
             break;
     }
 }
Exemplo n.º 10
0
    // Send message to server using socket connection.
    public new bool SendMessage(string message)
    {
        string[] tokens = message.Split(' ');
        if (!tokens[0].StartsWith("/"))
        {
            return(false);
        }

        switch (tokens[0])
        {
        case "/connect":
            if (tokens.Length < 3)
            {
                return(false);
            }

            try
            {
                int result = Int32.Parse(tokens[2]);
                ConnectToTcpServer(tokens[1], result);
                return(true);
            }
            catch (FormatException)
            {
                Console.WriteLine($"Unable to parse '{tokens[2]}'");
            }
            return(false);


        case "/all":
            if (tokens.Length < 2)
            {
                return(false);
            }
            ChatMessageOut worldMsg;
            worldMsg = new ChatMessageOut("world", string.Join(" ", tokens.Skip(1)));
            if (SendData(JsonUtility.ToJson(worldMsg)))
            {
                chat.addMessage(string.Format("[Ich an alle]: {0}", worldMsg.content));
            }
            break;

        case "/hello":
            if (tokens.Length < 2)
            {
                return(false);
            }
            HelloMsg helloMsg = new HelloMsg(tokens[1]);
            if (SendData(JsonUtility.ToJson(helloMsg)))
            {
                chat.addMessage("Hallo Server, ich heiße " + tokens[1]);
                gameController.playerName = tokens[1];
            }
            break;

        case "/to":
            ChatMessageOut chatMsg;
            if (tokens.Length > 2)
            {
                chatMsg = new ChatMessageOut(tokens[1], string.Join(" ", tokens.Skip(2)));
            }
            else
            {
                chatMsg = new ChatMessageOut(tokens[1], "");
            }
            if (SendData(JsonUtility.ToJson(chatMsg)))
            {
                chat.addMessage(string.Format("[Ich an {0}]: {1}", chatMsg.receiver, chatMsg.content));
            }
            break;

        case "/clear":
            chat.clearMessages();
            break;

        case "/getstate":
            GetStateMessage getStateMessage = new GetStateMessage();
            SendData(JsonUtility.ToJson(getStateMessage));
            break;
        }
        return(false);
    }