Example #1
0
 public static string SendGCM(string deviceID, Packet sendPacket)
 {
     GCMPacket gcm = new GCMPacket(new string[] { deviceID }, sendPacket);
     string postData = JsonConvert.SerializeObject(gcm);
     string response = SendGCMNotification(apiKey, postData);
     Console.ForegroundColor = ConsoleColor.Cyan;
     Console.WriteLine(DateTime.Now + ": GCM ===>" + response+"\n");
     Console.ForegroundColor = ConsoleColor.White;
     return response;
 }
Example #2
0
        static void DataManager(Packet p)
        {
            switch(p.packetType)
            {
                case PacketType.Registeration:
                    id = p.Gdata[0];
                    break;

                case PacketType.Chat:
                    ConsoleColor c = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Cyan;

                    Console.WriteLine(p.Gdata[0] + ":" + p.Gdata[1]);
                    Console.ForegroundColor = c;
                    break;

            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.Write("Enter your name:");
            name = Console.ReadLine();

            A:Console.Clear();
            Console.Write("Enter host IP Address:");
            string ip = Console.ReadLine();

            master = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp);

            IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(ip), 4242);

            try
            {
                master.Connect(ipe);
            }
            catch
            {
                Console.WriteLine("Could not work to host!");
                Thread.Sleep(1000);
                goto A;
            }

            Thread t = new Thread(Data_IN);
            t.Start();

            for(; ;)
            {
                Console.Write("::>");
                string input = Console.ReadLine();

                Packet p = new Packet(PacketType.Chat, id);
                p.Gdata.Add(name);
                p.Gdata.Add(input);
                master.Send(p.ToBytes());
            }
        }