Send() public method

public Send ( string message ) : string
message string
return string
Ejemplo n.º 1
0
        public void ProcessCommand(String method_name, String parameter_1, String parameter_2)
        {
            string category;
            string level;
            string osaid; //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used
            string messagedate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");;

            string payload;
            string strResponse;

            //look up address again in case it changed, but don't update if we get back a null or blank value (this probably means they renamed the object so looking up by the name we have returns nothing)
            //_gcmid = OSAEObjectManager.GetObjectByName(_name).Address;
            if (OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value != null)
            {
                if (!OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value.Equals(""))
                {
                    _gcmid = OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value;
                }
            }

            gcmsender.DeviceToken = _gcmid;

            switch (method_name)
            {
            case "NOTIFY":
                Log.Info("NOTIFY event triggered (" + _name + "), parameter_1=" + parameter_1 + ", parameter_2=" + parameter_2);
                Log.Debug("address = " + _gcmid);
                category = "default";
                level    = "5";
                osaid    = "-1";  //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used

                if (parameter_2 != "")
                {
                    string[] parts = parameter_2.Split(',');
                    if (parts.Length > 0)
                    {
                        category = parts[0];
                    }
                    if (parts.Length > 1)
                    {
                        level = parts[1];
                    }
                }
                payload     = "\"type\" : \"notification\" \"message\" : \"" + parameter_1 + "\" \"category\" : \"" + category + "\" \"level\" : \"" + level + "\" \"osaid\" : \"" + osaid + "\" \"messagedate\" : \"" + messagedate + "\" ";
                strResponse = gcmsender.Send(payload);
                Log.Debug("GCM response new version = " + strResponse);
                break;

            case "EXECUTE":
                Log.Info("EXECUTE event triggered (" + _name + "), parameter_1=" + parameter_1 + ", parameter_2=" + parameter_2);
                Log.Debug("address = " + _gcmid);
                category    = "#taskertask#";
                level       = "5";
                osaid       = "-1"; //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used
                payload     = "\"type\" : \"taskertask\" \"message\" : \"" + parameter_1 + "\" \"category\" : \"" + category + "\" \"level\" : \"" + level + "\" \"osaid\" : \"" + osaid + "\" \"messagedate\" : \"" + messagedate + "\" ";
                strResponse = gcmsender.Send(payload);
                Log.Debug("GCM response new version = " + strResponse);
                break;
            }
        }
        public void ProcessCommand(String method_name, String parameter_1, String parameter_2)
        {
            switch (method_name)
            {
            case "NOTIFY":

                //look up address again in case it changed
                //_gcmid = OSAEObjectManager.GetObjectByName(_name).Address;
                _gcmid = OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value;

                gcmsender.DeviceToken = _gcmid;

                log("NOTIFY event triggered (" + _name + "), parameter_1=" + parameter_1 + ", parameter_2=" + parameter_2, false);
                log("address = " + _gcmid, false);

                string category    = "default";
                string level       = "5";
                string osaid       = "-1"; //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used
                string messagedate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");;

                if (parameter_2 != "")
                {
                    string[] parts = parameter_2.Split(',');

                    if (parts.Length > 0)
                    {
                        category = parts[0];
                    }
                    if (parts.Length > 1)
                    {
                        level = parts[1];
                    }
                }


                string payload = "\"type\" : \"notification\" \"message\" : \"" + parameter_1 + "\" \"category\" : \"" + category + "\" \"level\" : \"" + level + "\" \"osaid\" : \"" + osaid + "\" \"messagedate\" : \"" + messagedate + "\" ";

                string strResponse = gcmsender.Send(payload);
                log("GCM response new version = " + strResponse, false);

                break;
            }
        }