コード例 #1
0
ファイル: Client.cs プロジェクト: ratulmukh/tashjik
        static TransportLayerCommunicator transportLayerCommunicator;         // = TransportLayerCommunicator.getRefTransportLayerCommunicator();

#if SIM
        public static void Main(string[] args)
        {
            Console.WriteLine("hello");
            //Console.WriteLine(args.Length);

            if (args.Length >= 1)
            {
                //byte[] byteIP = System.Text.Encoding.ASCII.GetBytes(args[0]);
                String[] IPsplit = args[0].Split(new char[] { '.' });
                Console.WriteLine("Hi there");

                IPAddress ipAddress = UtilityMethod.convertStrToIP(args[0]);

                UtilityMethod.SetLocalHostIP(ipAddress);
                Console.Write("received port=");
                Console.WriteLine(args[1]);
                UtilityMethod.SetPort(args[1]);

                transportLayerCommunicator = TransportLayerCommunicator.getRefTransportLayerCommunicator();

                //FileAppender fileAppender = new FileAppender();
                //	fileAppender.File = "E:/manga";
                //BasicConfigurator.Configure(fileAppender);
                //log.Info("hi");
                //string fn = @"e:\ratul\code\tashjik\logs\" + args[0]+ ".txt";
                //TextWriter errStream = new StreamWriter(fn);
                //Console.SetError(errStream);
                //Console.SetOut(errStream);
            }
コード例 #2
0
ファイル: DataReceiver.cs プロジェクト: ratulmukh/tashjik
        public static void Main()
        {
            TransportLayerCommunicator transportLayerCommunicator = TransportLayerCommunicator.getRefTransportLayerCommunicator();

            while (true)
            {
            }
        }
コード例 #3
0
        static TransportLayerCommunicator transportLayerCommunicator;         // = TransportLayerCommunicator.getRefTransportLayerCommunicator();

#if SIM
        public static void Main(string[] args)
        {
            Console.WriteLine("hello");
            //Console.WriteLine(args.Length);

            if (args.Length >= 1)
            {
                //byte[] byteIP = System.Text.Encoding.ASCII.GetBytes(args[0]);
                String[] IPsplit = args[0].Split(new char[] { '.' });
                Console.WriteLine("Hi there");

                IPAddress ipAddress = UtilityMethod.convertStrToIP(args[0]);

                UtilityMethod.SetLocalHostIP(ipAddress);
                Console.Write("received port=");
                Console.WriteLine(args[1]);
                UtilityMethod.SetPort(args[1]);

                transportLayerCommunicator = TransportLayerCommunicator.getRefTransportLayerCommunicator();
            }
コード例 #4
0
    static private void notifyUpperLayer(String content, Socket fromSock, TransportLayerCommunicator transportLayerCommunicator)
    {
        Console.WriteLine("Boxit::notifyUpperLayer ENTER");
        Console.WriteLine("Boxit::notifyUpperLayer content=\n{0}", content);
        Console.WriteLine("Boxit::notifyUpperLayer split contents=");
        String[] split = content.Split(new char[] { '\0' });
        foreach (String s in split)
        {
            Console.WriteLine(s);
        }
        byte[] byteContent = System.Text.Encoding.ASCII.GetBytes(content);

        String strFromIP      = null;
        String strToIP        = null;
        String strOverlayGuid = null;
        String strCallType    = null;

        byte[] byteOverlayGuid;
        Guid   overlayGuid = new Guid();;
        String strBuffer;

        byte[] byteBuffer;
        MsgExtractionStatus msgExtractionStatus = MsgExtractionStatus.NOTHING_EXTRACTED;

        foreach (String s in split)
        {
            if (msgExtractionStatus == MsgExtractionStatus.NOTHING_EXTRACTED || msgExtractionStatus == MsgExtractionStatus.MESSAGE_EXTRACTED)
            {
                if (s.Length == 0)
                {
                    break;
                }
                strFromIP = s;
                Console.WriteLine("FromIP received: {0}", s);
                msgExtractionStatus = MsgExtractionStatus.FROM_IP_EXTRACTED;
            }
            else if (msgExtractionStatus == MsgExtractionStatus.FROM_IP_EXTRACTED)
            {
                strToIP = s;
                Console.WriteLine("ToIP received: {0}", s);
                msgExtractionStatus = MsgExtractionStatus.TO_IP_EXTRACTED;
            }
            else if (msgExtractionStatus == MsgExtractionStatus.TO_IP_EXTRACTED)
            {
                strCallType = s;
                Console.WriteLine("haha 1\n{0}\n{1}", s, s.Length);
                //byteOverlayGuid = System.Text.Encoding.ASCII.GetBytes(strOverlayGuid);
                //overlayGuid = new Guid(s);
                msgExtractionStatus = MsgExtractionStatus.CALLTYPE_EXTRACTED;
            }
            else if (msgExtractionStatus == MsgExtractionStatus.CALLTYPE_EXTRACTED)
            {
                strOverlayGuid = s;
                Console.WriteLine("haha 1.5\n{0}\n{1}", s, s.Length);
                byteOverlayGuid     = System.Text.Encoding.ASCII.GetBytes(strOverlayGuid);
                overlayGuid         = new Guid(s);
                msgExtractionStatus = MsgExtractionStatus.OVERLAYGUID_EXTRACTED;
            }
            else if (msgExtractionStatus == MsgExtractionStatus.OVERLAYGUID_EXTRACTED)
            {
                strBuffer = s;
                Console.WriteLine("haha 2 \n {0}\n{1}", s, s.Length);
                byteBuffer = System.Text.Encoding.ASCII.GetBytes(strBuffer);

                //byte[] byteFromIP = System.Text.Encoding.ASCII.GetBytes(strFromIP);
                //IPAddress fromIP = new IPAddress(byteFromIP);

                IncomingMsg incomingMsg = new IncomingMsg();
                incomingMsg.strFromIP      = strFromIP;
                incomingMsg.strToIP        = strToIP;
                incomingMsg.strCallType    = strCallType;
                incomingMsg.strOverlayGuid = strOverlayGuid;
                incomingMsg.extractedMsg   = strBuffer;
                incomingMsg.completeMsg    = byteContent;
                incomingMsg.offset         = 0;
                incomingMsg.size           = byteContent.Length;
                ParameterizedThreadStart processMsgJob = new ParameterizedThreadStart(processMsg);
                Thread processMsgThread = new Thread(processMsgJob);
                processMsgThread.Start(incomingMsg);
                //processMsg(strFromIP, strToIP, strOverlayGuid, strBuffer, byteContent, 0, byteContent.Length);
                msgExtractionStatus = MsgExtractionStatus.MESSAGE_EXTRACTED;
            }
        }
    }