示例#1
0
        static void Main(string[] args)
        {
            Console.Write("Input server name : ");
            string hostName = Console.ReadLine();
            string ip       = "";

            string portStr = ConfigurationManager.AppSettings["ServerPort"];
            int    port    = 0;

            if (!string.IsNullOrEmpty(portStr))
            {
                port = Convert.ToInt32(portStr);
            }

            foreach (IPAddress ipaddress in Dns.GetHostEntry(hostName).AddressList)
            {
                if (ipaddress.AddressFamily == AddressFamily.InterNetwork)
                {
                    ip = ipaddress.ToString();
                }
                break;
            }
            if (ip != "")
            {
                tcpCommand = new GSMClient.TcpCommand(ip, port, new DefaultConfigurationKey());
                //client = new GSMClient.Client(ip, port, new DefaultConfigurationKey());
            }
            else
            {
                //client = new GSMClient.Client(hostName, port, new DefaultConfigurationKey());
                tcpCommand = new GSMClient.TcpCommand(hostName, port, new DefaultConfigurationKey());
            }

            //client.Signature = ConfigurationManager.AppSettings["SMSGWSignature"];
            //client.Open();
            tcpCommand.Connection.Open();
            Console.WriteLine("Connection established {0}\n", ((TcpConnection)tcpCommand.Connection).TcpClient.Client.RemoteEndPoint);
            Console.WriteLine("Format Command:");
            Console.WriteLine("[InterfaceName].[MethodName](+param: [YourParameterName]=[YourValue])\n");
            Console.WriteLine("if your parameter more than one\n");
            Console.WriteLine("[InterfaceName].[MethodName](+param: [YourParameterName1]=[YourValue1] +param: [YourParameterName2]=[YourValue2])\n");
            Console.WriteLine("Example:");
            Console.WriteLine("ISMS.Send(+param: Number=08111 +param: Message=Hello)");
            Console.WriteLine("ICall.SendUSSD(+param: Code=1 +param: Number=*111#)");
            Console.WriteLine();
            //Send(client.GetTcpClient());
            Send(((TcpConnection)tcpCommand.Connection).TcpClient);
            Console.ReadKey();
        }
示例#2
0
        public  TcpService(string ipAddress, int port)
        { 
            if (string.IsNullOrEmpty(ipAddress))
            {
                throw new ArgumentNullException("IPAddress");
            }
            if (port == 0)
            {
                throw new ArgumentNullException("Port");
            }

            gsmCommand = new TcpCommand(ipAddress, port, new ApplicationSettingKeySym());
            Connection = new TcpConnection(gsmCommand); 
             
        } 
示例#3
0
        static void Main(string[] args)
        { 
            Console.Write("Input server name : " );
            string hostName = Console.ReadLine();
            string ip = "";

            string portStr = ConfigurationManager.AppSettings["ServerPort"];
            int port = 0;
            if (!string.IsNullOrEmpty(portStr))
                port = Convert.ToInt32(portStr);

            foreach (IPAddress ipaddress in Dns.GetHostEntry(hostName).AddressList)
            {
                if (ipaddress.AddressFamily == AddressFamily.InterNetwork)
                    ip = ipaddress.ToString();
                break;
            }
            if (ip != "")
            {
                tcpCommand = new GSMClient.TcpCommand(ip, port, new DefaultConfigurationKey());
                //client = new GSMClient.Client(ip, port, new DefaultConfigurationKey());
            }
            else
            {
                //client = new GSMClient.Client(hostName, port, new DefaultConfigurationKey());
                tcpCommand = new GSMClient.TcpCommand(hostName, port, new DefaultConfigurationKey());
            }

            //client.Signature = ConfigurationManager.AppSettings["SMSGWSignature"];
            //client.Open();
            tcpCommand.Connection.Open();
            Console.WriteLine("Connection established {0}\n", ((TcpConnection)tcpCommand.Connection).TcpClient.Client.RemoteEndPoint);
            Console.WriteLine("Format Command:");
            Console.WriteLine("[InterfaceName].[MethodName](+param: [YourParameterName]=[YourValue])\n");
            Console.WriteLine("if your parameter more than one\n");
            Console.WriteLine("[InterfaceName].[MethodName](+param: [YourParameterName1]=[YourValue1] +param: [YourParameterName2]=[YourValue2])\n");
            Console.WriteLine("Example:");
            Console.WriteLine("ISMS.Send(+param: Number=08111 +param: Message=Hello)");
            Console.WriteLine("ICall.SendUSSD(+param: Code=1 +param: Number=*111#)");
            Console.WriteLine();
            //Send(client.GetTcpClient());
            Send(((TcpConnection)tcpCommand.Connection).TcpClient);
            Console.ReadKey();
        }