Пример #1
0
        public static SocketStore getInstance()
        {
            if (instance == null)
            {
                instance = new SocketStore();
            }

            return(instance);
        }
Пример #2
0
        public void initComponents()
        {
            //instances
            serverPart     = ServerPart.getInstance();
            clientPart     = ClientPart.getInstance();
            socketStore    = SocketStore.getInstance();
            reciever       = new Reciever();
            sender         = Sender.getInstance();
            encoder        = Encoder.getInstance();
            controlHandler = ControlHandler.getInstance();


            fileShareController = new FileShareMiddleController();


            //events registering
            registerEvnts();

            //starting
            //serverPart.startServer();
        }
Пример #3
0
        private void sendControlMessage(string iptoken, Control control, string data)
        {
            Socket sck = SocketStore.getInstance().getSocket(iptoken);

            string msg = settings.Default.controlPrefix +
                         control.ToString() +
                         settings.Default.controlPostfix +
                         data;

            Console.WriteLine("sending control message: " + msg + "\ncontrol message sending to:" + iptoken);

            byte[] sendBuffer = Encoding.Default.GetBytes(msg);

            try
            {
                sck.Send(sendBuffer, 0, sendBuffer.Length, 0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }