Ejemplo n.º 1
0
        void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
        {
            String txt = Program.gui.you.Text;
            String s   = session.inputPack.GetFieldByName("Text").GetString();

            Form1.SetControlPropertyThreadSafe(Program.gui.you, "Text", txt + "\r\nNewInputFrame\r\n" + s);
        }
Ejemplo n.º 2
0
 static void WaitBytes(BabylonMS.BMSEventSessionParameter psession)
 {
     for (int i = 0; i < 1; i++)
     {
         Application.DoEvents();
     }
 }
Ejemplo n.º 3
0
        void ClientConnected(BabylonMS.BMSEventSessionParameter session)
        {
            Session = session;
            String txt = Program.gui.you.Text;

            Form1.SetControlPropertyThreadSafe(Program.gui.you, "Text", txt + "\r\nConnected");
        }
Ejemplo n.º 4
0
        //void NewAndroidConnected(TcpClient client, StreamReader reader, StreamWriter writer)
        void NewAndroidConnected(BabylonMS.BMSEventSessionParameter session)
        {
            Console.WriteLine("Android Connected");
            AndroidDescriptor thisAndroid = new AndroidDescriptor(session);

            if (!Program.DEBUG_InputControllerOnly)
            {
                thisAndroid.bms_imagebuffer                = BabylonMS.BabylonMS.LaunchMiniShip(Program.ip_imagebuffer, Program.port_imagebuffer, ImageBuffer.ImageBufferUUID, ImageBuffer.ImageBufferUUID, Program.instanceUUID); //UUID
                thisAndroid.bms_imagebuffer.IsReady        = false;
                thisAndroid.bms_imagebuffer.NewInputFrame += InputFrame_fromImageBuffer;
                thisAndroid.bms_imagebuffer.Disconnected  += (ses) =>
                {
                    Console.WriteLine("Disconnect from imagebuffer");
                };
                thisAndroid.bms_imagebuffer.Connected += (ses) =>
                {
                    thisAndroid.bms_imagebuffer.Tag = ses;
                    AndroidsList.Add(thisAndroid);
                };
                thisAndroid.bms_imagebuffer.PrepareGate();//Nonblocking   net Client
                while ((!thisAndroid.bms_imagebuffer.IsReady))
                {
                    Thread.Sleep(100);
                }
                ;
                //although the device connected but need time so device can retrieve all windows
                //Message_To_ImageBuffer_CONST_COMMAND_RETRIEVE(thisAndroid, (BabylonMS.BMSEventSessionParameter)thisAndroid.bms_imagebuffer.Tag);
                Console.WriteLine("Android personal Imagebuffer Connected ");
            }
            else
            {
                AndroidsList.Add(thisAndroid);
                Console.WriteLine("Inputcontroller only so Android personal Imagebuffer not connected");
            }
        }
Ejemplo n.º 5
0
        //void InputFrame_fromImageBuffer(String partnerUUID, BabylonMS.BMSPack imagebufferPack, StreamReader imagebufferReader, StreamWriter imagebufferWriter)
        void InputFrame_fromImageBuffer(BabylonMS.BMSEventSessionParameter imagebuffersession)
        {
            // The Imgebuffer sent some hwnd image data
            //please send to requester android
            try
            {
                byte              cmd         = (byte)imagebuffersession.inputPack.GetFieldByName("CMD").getValue(0);
                Int64             ID          = (Int64)imagebuffersession.inputPack.GetFieldByName("REQID").getValue(0);
                AndroidDescriptor thisAndroid = getAndroidDescriptor(ID);

                switch (cmd)
                {
                case VRCEShared.CONST_COMMAND_RETRIEVE:
                    if (imagebuffersession.inputPack.FieldsCount() > 2)
                    {
                        BabylonMS.BMSPack pack = new BabylonMS.BMSPack();
                        pack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(VRCEShared.CONST_ANDROIDCOMMAND_RETRIEVE_ALL);
                        pack.AddField("PCKCNT", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)thisAndroid.sentPackCounter++);
                        int cnt = (imagebuffersession.inputPack.FieldsCount() - 2) / 3;
                        for (int i = 0; i < cnt; i++)
                        {
                            byte idx = (byte)imagebuffersession.inputPack.GetField((i * 4) + 2).getValue(0);
                            pack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value(idx);
                            pack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(imagebuffersession.inputPack.GetField((i * 4) + 3).getValue(0));
                            pack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(imagebuffersession.inputPack.GetField((i * 4) + 4).GetUUIDValue(0));
                            pack.AddField("IMAGE", BabylonMS.BabylonMS.CONST_FT_BYTE).Value(imagebuffersession.inputPack.GetField((i * 4) + 5).getValue());
                        }
                        BabylonMS.BabylonMS.TransferPacket(thisAndroid.writer, pack, true, thisAndroid.locker);      //transfer images to requester android
                    }
                    break;
                }
            }
            finally { }
        }
Ejemplo n.º 6
0
        void ReadyForTransfer(BabylonMS.BMSEventSessionParameter session)
        {
            Session = session;
            String txt = Program.gui.me.Text;

            Form1.SetControlPropertyThreadSafe(Program.gui.me, "Text", txt + "\r\nReadyForTransfer");
        }
Ejemplo n.º 7
0
 void ReadyForTransfer(BabylonMS.BMSEventSessionParameter session)
 {
     bms.Disengage();
     ready       = true;
     windowslist = new WindowsList(2f);
     Console.WriteLine("ImageBuffer started (WindowsList created)");
 }
Ejemplo n.º 8
0
 void ReadyForTransfer(BabylonMS.BMSEventSessionParameter session)
 {
     //BabylonMS.Util.setNextProcessorCyclic();
     Console.WriteLine("WindowsList started (WindowsList created)");
     session.outputPack.setMinTimeWithoutStart((uint)(1000 / FPS));
     session.outputPack.SetAttribs(BabylonMS.BabylonMS.CONST_Continous);
     session.TransferPacket(true); //request
 }
Ejemplo n.º 9
0
 static void Connected(BabylonMS.BMSEventSessionParameter psession)
 {
     if (debug)
     {
         Console.WriteLine("InputController Connected.");
     }
     session = psession;
     hook    = new MouseHooker();
 }
Ejemplo n.º 10
0
        //int cnt = 0;
        private void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
        {
            Task t2 = Task.Factory.StartNew(() =>
            {
                Program.androids.sendNoticeToAndroidsNewContent(session);

                //Thread.Sleep(500);
                //throw new NotImplementedException();
            });
        }
Ejemplo n.º 11
0
 static void NewInputFrame(BabylonMS.BMSEventSessionParameter session) //newinput frame or continuous
 {
     try
     {
         lista();
         bms.TransferPacket(session.writer, outputpack, false);
         outputpack.Clear();
     }
     catch (Exception) { };
 }
Ejemplo n.º 12
0
 void ReadyForTransfer(BabylonMS.BMSEventSessionParameter session)
 {
     screensession = session;
     BabylonMS.Util.setNextProcessorCyclic();
     IBIface = new ImageBufferInterface();
     Console.WriteLine("ScreenCapture started" + Hwnd.ToString("X"));
     session.outputPack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(VRCEShared.CONST_CAPTURE_START); //hwnd = new IntPtr(Int64.Parse(chd.Attributes["handle"].Value));
     session.outputPack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(Hwnd);                         //hwnd = new IntPtr(Int64.Parse(chd.Attributes["handle"].Value));
     session.outputPack.AddField("MINTIME", BabylonMS.BabylonMS.CONST_FT_INT32).Value((int)(1000 / FPS));         //MINTIME direkt elküldve
     //session.outputPack.setMinTimeWithoutStart((uint)(1000 / FPS));
     //session.outputPack.SetAttribs(BabylonMS.BabylonMS.CONST_Continous);
     session.TransferPacket(true); //request
 }
Ejemplo n.º 13
0
        //T O  A N D R O I D
        //public void sendNoticeToAndroidsNewContent(BabylonMS.BMSPack inputpack, StreamReader reader, StreamWriter writer)
        public void sendNoticeToAndroidsNewContent(BabylonMS.BMSEventSessionParameter session)
        {
            BabylonMS.BMSPack androidpack;
            foreach (AndroidDescriptor android in AndroidsList)
            {
                try
                {
                    if (android.isEnabled(session))  //adott android mit kaphat meg...
                    {
                        byte cmd = (byte)session.inputPack.GetFieldByName("CMD").getValue(0);
                        switch (cmd)
                        {
                        case VRCEShared.CONST_COMMAND_STORE:     //->CONST_ANDROIDCOMMAND_CHANGE_HWND
                            //Translate pack
                            androidpack = new BabylonMS.BMSPack();
                            session.inputPack.CopyTo(androidpack);
                            androidpack.GetFieldByName("CMD").clearValue().Value(VRCEShared.CONST_ANDROIDCOMMAND_CHANGE_HWND);      //ClearValue because addarray to next position (2.)
                            androidpack.AddField("PCKCNT", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)android.sentPackCounter++);
                            BabylonMS.BabylonMS.TransferPacket(android.writer, androidpack, true, android.locker);
                            break;

                        case VRCEShared.CONST_ANDROIDCOMMAND_LOST_WINDOW:
                            androidpack = session.inputPack;
                            androidpack.AddField("PCKCNT", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)android.sentPackCounter++);
                            BabylonMS.BabylonMS.TransferPacket(android.writer, androidpack, true, android.locker);
                            break;

                        case VRCEShared.CONST_IC_EVENT:     //->CONST_ANDROIDCOMMAND_IC_EVENT
                            androidpack = new BabylonMS.BMSPack();
                            session.inputPack.CopyTo(androidpack);
                            androidpack.GetFieldByName("CMD").clearValue().Value(VRCEShared.CONST_ANDROIDCOMMAND_IC_EVENT);      //ClearValue because addarray to next position (2.)
                            ScreenCapture focused = ScreenCapture.getFocused();
                            if (focused != null)
                            {
                                androidpack.AddField("LEFT", BabylonMS.BabylonMS.CONST_FT_INT16).Value((Int16)ScreenCapture.frame[0]);
                                androidpack.AddField("TOP", BabylonMS.BabylonMS.CONST_FT_INT16).Value((Int16)ScreenCapture.frame[1]);
                            }
                            androidpack.AddField("PCKCNT", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)android.sentPackCounter++);
                            BabylonMS.BabylonMS.TransferPacket(android.writer, androidpack, true, android.locker);
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 14
0
        void NewInputFrame(BabylonMS.BMSEventSessionParameter session) //from ScreenCapture
        {
            BabylonMS.BMSField rect = session.inputPack.GetFieldByName("RECT");
            if (rect != null)
            {
                try
                {
                    if ((focused != null) && (focused == this))
                    {
                        frame[0] = (Int16)rect.getValue(0);
                        frame[1] = (Int16)rect.getValue(1);
                        frame[2] = (Int16)rect.getValue(2);
                        frame[3] = (Int16)rect.getValue(3);
                    }
                }
                catch (Exception) { }
            }
            byte[] buffer = session.inputPack.GetField(0).getValue();


            if (++CCC1 % 50 == 0)
            {
                Console.WriteLine("Inputframenum:" + CCC1.ToString());
            }
            {
                {
                    //Store screencapture image to Imagebuffer
                    IBIface.session.outputPack.Clear();
                    IBIface.session.outputPack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).
                    Value(VRCEShared.CONST_COMMAND_STORE);
                    IBIface.session.outputPack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).
                    Value(Hwnd);
                    IBIface.session.outputPack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).
                    ValueAsUUID(Program.instanceUUID);
                    IBIface.session.outputPack.AddField("IMAGE", BabylonMS.BabylonMS.CONST_FT_BYTE).
                    Value(buffer);
                    try
                    {
                        IBIface.session.TransferPacket(true); //to Imagebuffer
                    }
                    catch (Exception)
                    {
                    }
                    //I Don't check buffered or not
                    // Partner class start Notice with modified content to Partner
                }
            }
        }
Ejemplo n.º 15
0
 void Disconnect(BabylonMS.BMSEventSessionParameter session) //And reconnect
 {
     Console.WriteLine("ScreenContent disconnect window content not reachable. " + Hwnd.ToString("X"));
     //screen capture class need to remove from handles list and
     session.inputPack.ClearFields();
     session.inputPack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(VRCEShared.CONST_ANDROIDCOMMAND_LOST_WINDOW);
     session.inputPack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(Hwnd);
     session.inputPack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(Program.instanceUUID); //TODO ezt 't kell gondolni hogy  tényleg ezt kell e küldeni.. de valszeg igen
     Program.androids.sendNoticeToAndroidsNewContent(session);                                                 // inputpack,reader,writer);//So the partner will send a request for imagebuffer on TCP
     //IBIface.Disconnect(session);
     HandlesList.Remove(Hwnd, HandlesList.windows);
     if (focused == this)
     {
         focused = null;
     }
 }
Ejemplo n.º 16
0
 void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
 {
     try
     {
         //Console.Write("L ");
         foreach (BabylonMS.BMSField f in session.inputPack.GetFields())
         {
             Int64 hwnd = f.getValue(0);
             HandlesList.Add(hwnd, HandlesList.windows);
         }
         //Int64 buffer = session.inputPack.GetField(0).getValue(0);
         //Console.Write("arrived. ");
     }
     catch (Exception) {
         Console.WriteLine("Error.");
     }
 }
Ejemplo n.º 17
0
        // az aktuális pack tartalom engedélyezve?
        public bool isEnabled(BabylonMS.BMSEventSessionParameter session)
        {
            BabylonMS.BMSPack pack = session.inputPack;
            if (selection.Count() < 1)
            {
                return(true);
            }                                          //if empty the selection list then accepted (all types)
            long cmd = pack.GetField(0).getValue(0);   //CMD

            if (cmd == VRCEShared.CONST_COMMAND_STORE) //now only one type of IMAGEPACK
            {
                long   hwnd  = pack.GetFieldByName("HWND").getValue(0);
                String group = pack.GetFieldByName("GROUP").GetUUIDValue(0);
                if (selection.Find(x => ((x.type == Selection.CONST_PACKTYPE_IMAGE) && (x.hwnd == hwnd) && (x.hwndgroupUUID == group))) != null)
                {
                    return(true);  //found STORE/HWND data
                }
                else
                {
                    if (selection.Find(x => ((x.type == Selection.CONST_PACKTYPE_IMAGE))) == null)
                    { //ebben a t\pusban egy'ltal'n nincs adat akkor elfogadva
                        return(true);
                    }
                }
                return(false);
            }
            //check mouse
            if (cmd == VRCEShared.CONST_IC_EVENT)
            {
                String mouseUUID = session.shipUUID;

                if (selection.Find(x => ((x.type == Selection.CONST_PACKTYPE_CONTROLLER) && (x.mouseUUID == mouseUUID))) != null)
                {
                    return(true);  //found stored data erre az egérre fel van iratkozva
                }
                else
                {
                    if (selection.Find(x => ((x.type == Selection.CONST_PACKTYPE_CONTROLLER))) == null)
                    { //ebben a t\pusban egy'ltal'n nincs adat akkor úgy vesszük fel van iratkozva rá
                        return(true);
                    }
                }
            }

            return(false);  //unknown pack CMD
        }
Ejemplo n.º 18
0
 static void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
 {
     if (debug)
     {
         Console.WriteLine("NEW INPUT PACK");
     }
     if (session.inputPack.FieldsCount() > 0)
     {
         BabylonMS.BMSPack outputpack = new BabylonMS.BMSPack();
         byte command = (byte)session.inputPack.GetField(0).getValue(0);
         switch (command)
         {
         case VRMainContentExporter.VRCEShared.CONST_IC_MODE:
             //outputpack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)buf.position_in_buffer);
             //bms.TransferPacket(session.writer, outputpack, true);
             break;
         }
     }
 }
Ejemplo n.º 19
0
        //public AndroidDescriptor(TcpClient client, StreamReader reader, StreamWriter writer)
        public AndroidDescriptor(BabylonMS.BMSEventSessionParameter session)
        {
            sentPackCounter = 0;
            locker          = new Semaphore(1, 1); //for one android
            bool isFirstTime;

            selection    = new List <Selection>(); //empty yet so all types is accepted
            this.session = session;
            this.reader  = session.reader;
            this.writer  = session.writer;
            this.client  = session.client;
            try
            {
                //Console.WriteLine(reader.CurrentEncoding.ToString());
                ID = Program.IDGenerator.GetId(client, out isFirstTime); //The client ID from reader instance unique ID
            }
            catch (Exception) {
                Console.WriteLine("ID not created bad stream.");
            }
        }
Ejemplo n.º 20
0
        void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
        {
            //Console.Write("Answer for imagebuffer store command ");

            bool needRefresh = session.inputPack.GetFieldByName("REFRESH").getBoolValue(0);

            if (needRefresh)
            {
                //Console.Write(" and need refresh.");
                if (session.inputPack.GetFieldByName("IMAGE") == null)
                {
                    //Console.Write(" Without image.");
                }
                //Console.WriteLine();
                Program.androids.sendNoticeToAndroidsNewContent(session);// inputpack,reader,writer);//So the partner will send a request for imagebuffer on TCP
            }
            else
            {   //no image info in pack
                //Console.WriteLine();
            }
        }
Ejemplo n.º 21
0
        static void NewInputFrame(BabylonMS.BMSEventSessionParameter session)
        {
            screensession = session;
            BabylonMS.BMSField cmdfield = session.inputPack.GetField(0);
            byte cmd = (byte)cmdfield.getValue(0);//CMD

            switch (cmd)
            {
            case VRMainContentExporter.VRCEShared.CONST_CAPTURE_START:
            {
                Int64 inp = session.inputPack.GetFieldByName("HWND").getValue(0);
                mintime = (uint)session.inputPack.GetFieldByName("MINTIME").getValue(0);
                if (inp == 0)
                {
                    hwnd = ContentCapture.User32.GetDesktopWindow();         //desktop
                }
                else
                {
                    hwnd = new IntPtr(inp);         //Window
                }
                datavalid = true;
                break;
            }

            case VRMainContentExporter.VRCEShared.CONST_CAPTURE_FOCUS_WINDOW:
            {
                //mert a következő Continous miatt ennek kell lennie
                //cmdfield.clearValue().Value(VRMainContentExporter.VRCEShared.CONST_CAPTURE_START);
                if (hwnd != IntPtr.Zero)
                {
                    ContentCapture.User32.ForceWindowToForeground(hwnd);
                    ContentCapture.User32.SetForegroundWindow(hwnd);
                    restrictArea(hwnd, true, false);
                }
                break;
            }
            }
        }
Ejemplo n.º 22
0
 public void Waitbytes(BabylonMS.BMSEventSessionParameter session)
 {
     //Console.Write("W ");
 }
Ejemplo n.º 23
0
        //F R O M   A N D R O I D
        //void InputFrame_fromAnAndroid(String partnerUUID, BabylonMS.BMSPack pack, TcpClient client, StreamReader reader, StreamWriter writer)
        void InputFrame_fromAnAndroid(BabylonMS.BMSEventSessionParameter session)
        {
            AndroidDescriptor thisAndroid = getAndroidDescriptor(session.client);

            //Nothing
            //- direct retrieve images
            //- setup mouse behaviour
            // etc... select requested images
            byte cmd = (byte)session.inputPack.GetField(0).getValue(0);

            switch (cmd)
            {
            case VRCEShared.CONST_ANDROIDCOMMAND_SUBSCRIBE_HWND:      //subscribe hwnd
                break;

            case VRCEShared.CONST_ANDROIDCOMMAND_SUBSCRIBE_TYPE:      //subscribe type (images,mouse,keyboard....
                break;

            case VRCEShared.CONST_ANDROIDCOMMAND_RETRIEVE_HWND:      //Direct retrieve a buffer element if need independently from refresh
            {
                //TODO szerintem nincs kész nem tesztelt...!

                //request from IMAGEBUFFER
                byte index = (byte)session.inputPack.GetField(1).getValue(0);
                //Request imagebuffer on tcp
                session.outputPack.Clear();
                session.outputPack.SetAttribs(BabylonMS.BabylonMS.CONST_AutosendOutputpack);                                        //A felkapcsolódás után az alábbi packot fogja elküldeni vissza
                                                                                                                                    //Így megspórolhatunk egy event-et és nem várunk semmire
                session.outputPack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(VRCEShared.CONST_COMMAND_RETRIEVE_IDX); //TODO
                session.outputPack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value(index);
                session.TransferPacket(true);
            }
            break;

            case VRCEShared.CONST_ANDROIDCOMMAND_RETRIEVE_ALL:     //Elküldi a legfrissebb tartalmat minden feliratkozott képről.(feliratkozások minden Androidhoz előzőleg letárolva)
            {
                //Message_To_ImageBuffer_CONST_COMMAND_RETRIEVE(thisAndroid,session.);
                Message_To_ImageBuffer_CONST_COMMAND_RETRIEVE(thisAndroid, (BabylonMS.BMSEventSessionParameter)thisAndroid.bms_imagebuffer.Tag);
                Console.WriteLine("First retrieve for imagebuffer");
            }
            break;

            case VRCEShared.CONST_ANDROIDCOMMAND_FOCUS_WINDOW:      //Rááll egy ablakra
                //TODO kapcsolt hálózat? egyelőre ez a gép
            {
                String groupUUID = session.inputPack.GetFieldByName("GROUP").GetUUIDValue(0);
                if (BabylonMS.BabylonMS.compareUUID(Program.instanceUUID, groupUUID))
                {
                    //this instance
                    Int64       hwnd = session.inputPack.GetFieldByName("HWND").getValue(0);
                    HandlesList win  = HandlesList.getw(hwnd, HandlesList.windows);
                    if (win != null)
                    {
                        win.sc.BringToFront();
                    }
                }

                break;
            }
            }
        }
Ejemplo n.º 24
0
 static void ClientConnected(BabylonMS.BMSEventSessionParameter session)
 {
     //session.inputPack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64);  //hwnd = new IntPtr(Int64.Parse(chd.Attributes["handle"].Value));
     session.outputPack.AddField("DATA", BabylonMS.BabylonMS.CONST_FT_BYTE);
     session.outputPack.AddField("RECT", BabylonMS.BabylonMS.CONST_FT_INT16);
 }
Ejemplo n.º 25
0
 static void Disconnected(BabylonMS.BMSEventSessionParameter session)
 {
     Environment.Exit(0);
 }
Ejemplo n.º 26
0
 public void Connected(BabylonMS.BMSEventSessionParameter session) //And reconnect
 {
     this.session = session;
     //Console.WriteLine("Connected1");
 }
Ejemplo n.º 27
0
        static void InputFrame(BabylonMS.BabylonMS bms, BabylonMS.BMSEventSessionParameter session) //newinput frame or continuous
        {
            String partnerUUID = session.shipUUID;


            bool  isFirstTime;
            Int64 ID = IDGenerator.GetId(session.reader, out isFirstTime); //The client ID from reader instance unique ID

            try
            {
                /*
                 * //Az inputpack paramétermintázatának ellenőrzésére szolgál (nem szükséges)
                 * //Elválasztva egymás után a paramétermintázatok.
                 * session.inputPack.AcceptedEnergyPattern(new byte[] {
                 *  BabylonMS.BabylonMS.CONST_FT_INT8,BabylonMS.BabylonMS.CONST_FT_INT64,BabylonMS.BabylonMS.CONST_FT_BYTE,BabylonMS.BabylonMS.CONST_FT_END,
                 *  BabylonMS.BabylonMS.CONST_FT_INT8,BabylonMS.BabylonMS.CONST_FT_INT64,BabylonMS.BabylonMS.CONST_FT_END
                 * }
                 * );
                 */

                byte command = (byte)session.inputPack.GetField(0).getValue(0);
                BabylonMS.BMSPack outputpack = new BabylonMS.BMSPack();
                Int64             hwnd;
                String            group;
                String            key;
                MediaBuffer       buf;
                //String owner = partnerUUID;
                switch (command)
                {
                case VRMainContentExporter.VRCEShared.CONST_COMMAND_GETBUFFER:
                    //TODO : NOT TESTED
                    outputpack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(command);
                    //bool first = true;
                    BabylonMS.BMSField f1 = null;
                    BabylonMS.BMSField f2 = null;
                    BabylonMS.BMSField f3 = null;
                    BabylonMS.BMSField f4 = null;
                    BabylonMS.BMSField f5 = null;
                    int  cnt = mediaserver.SIBuffer.Count();
                    byte idx = 0;
                    for ( ; idx < cnt; idx++)
                    {
                        buf = mediaserver.SIBuffer[idx];
                        if (idx == 0)
                        {
                            f1 = outputpack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8);
                            f2 = outputpack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64);
                            f3 = outputpack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID);     //UUID length string array
                            f4 = outputpack.AddField("DATE", BabylonMS.BabylonMS.CONST_FT_INT64);
                            f5 = outputpack.AddField("USAGE", BabylonMS.BabylonMS.CONST_FT_INT32);
                        }
                        f1.Value(idx);
                        f2.Value(buf.hwnd);
                        f3.ValueAsUUID(buf.owner);     //mivel owner = UUID
                        f4.Value(buf.created.Ticks);
                        f5.Value(buf.usage);
                    }
                    if (idx > 0)
                    {
                        bms.TransferPacket(session.writer, outputpack, true);
                    }
                    break;

                case VRMainContentExporter.VRCEShared.CONST_COMMAND_EXIST:
                    //TODO : NOT TESTED
                    hwnd  = session.inputPack.GetFieldByName("HWND").getValue(0);
                    group = session.inputPack.GetFieldByName("GROUP").GetUUIDValue(0);
                    key   = System.Text.Encoding.ASCII.GetString(session.inputPack.GetField(2).getValue());
                    outputpack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(command);
                    outputpack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(hwnd);
                    outputpack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(group);
                    sema1.WaitOne();
                    outputpack.AddField("EXISTS", BabylonMS.BabylonMS.CONST_FT_INT8).Value(mediaserver.Exists(group, key, hwnd));
                    sema1.Release();
                    bms.TransferPacket(session.writer, outputpack, true);
                    break;

                case VRMainContentExporter.VRCEShared.CONST_COMMAND_STORE:
                    hwnd  = session.inputPack.GetFieldByName("HWND").getValue(0);
                    group = session.inputPack.GetFieldByName("GROUP").GetUUIDValue(0);
                    byte[] image = session.inputPack.GetFieldByName("IMAGE").getValue();
                    sema1.WaitOne();
                    byte[] res     = mediaserver.indexOfBufferAndStore(group, MediaServer.md5(image), image, hwnd);
                    bool   refresh = clientFollower.IsNeedRefresh(ID, res[0], res[1]);
                    sema1.Release();
                    outputpack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(command);
                    outputpack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(hwnd);
                    outputpack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(group);
                    outputpack.AddField("MODE", BabylonMS.BabylonMS.CONST_FT_INT8).Value(res[0]);
                    outputpack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value(res[1]);
                    outputpack.AddField("REFRESH", BabylonMS.BabylonMS.CONST_FT_INT8).Value(refresh);
                    if ((refresh) && (res[0] != VRMainContentExporter.VRCEShared.CONST_MODE_BFFOUND))
                    {
                        MediaBuffer buf2 = mediaserver.Retrieve(res[1]);
                        if (buf2 != null)
                        {
                            outputpack.AddField("IMAGE", BabylonMS.BabylonMS.CONST_FT_BYTE).Value(buf2.buffer);
                        }
                    }
                    bms.TransferPacket(session.writer, outputpack, true);
                    //Console.WriteLine();
                    break;

                case VRMainContentExporter.VRCEShared.CONST_COMMAND_RETRIEVE:
                    outputpack.AddField("CMD", BabylonMS.BabylonMS.CONST_FT_INT8).Value(command);
                    Int64 androidReqID = session.inputPack.GetFieldByName("REQID").getValue(0);
                    outputpack.AddField("REQID", BabylonMS.BabylonMS.CONST_FT_INT64).Value(androidReqID);
                    if (session.inputPack.FieldsCount() > 2)
                    {
                        //TODO mert nem ellenőriztem ;s mert lehet hogy a UUID+HWND parost kellene lek;rdezni!!!!
                        for (int i = 2; i < session.inputPack.FieldsCount(); i += 2)   //CMD in first position
                        {
                            hwnd  = session.inputPack.GetField(i).getValue(0);
                            group = session.inputPack.GetField(i + 1).GetUUIDValue(0);
                            sema1.WaitOne();
                            buf = mediaserver.Retrieve(group, hwnd);
                            outputpack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)buf.position_in_buffer);
                            outputpack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64).Value(hwnd);
                            outputpack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(group);
                            outputpack.AddField("IMAGE", BabylonMS.BabylonMS.CONST_FT_BYTE).Value(buf.buffer);
                            sema1.Release();
                        }
                    }
                    else
                    {
                        //All uptodate element from buffer because no specified sent HWND
                        List <string> owners = mediaserver.GetOwners();
                        foreach (var o in owners)
                        {
                            List <Int64> hwnds = mediaserver.GetOwnerHwnds(o);
                            foreach (var h in hwnds)
                            {
                                sema1.WaitOne();
                                buf = mediaserver.Retrieve(o, h);
                                if (buf != null)
                                {
                                    outputpack.AddField("IDX", BabylonMS.BabylonMS.CONST_FT_INT8).Value((byte)buf.position_in_buffer);
                                    BabylonMS.BMSField fi = outputpack.AddField("HWND", BabylonMS.BabylonMS.CONST_FT_INT64);
                                    fi.Value(h);
                                    outputpack.AddField("GROUP", BabylonMS.BabylonMS.CONST_FT_UUID).ValueAsUUID(o);
                                    outputpack.AddField("IMAGE", BabylonMS.BabylonMS.CONST_FT_BYTE).Value(buf.buffer);
                                }
                                sema1.Release();
                            }
                        }
                    }
                    bms.TransferPacket(session.writer, outputpack, true);
                    break;
                }
            }
            catch (Exception) {
            };
        }
Ejemplo n.º 28
0
 static void TCPNewInputFrame(BabylonMS.BMSEventSessionParameter session)
 {
     InputFrame(tcp, session);
 }
Ejemplo n.º 29
0
 static void TCPDisconnected(BabylonMS.BMSEventSessionParameter session)
 {
     //Console.WriteLine("TCP Server Disconnected");
 }
Ejemplo n.º 30
0
 public void Disconnect(BabylonMS.BMSEventSessionParameter session) //And reconnect
 {
     Console.WriteLine("Disengage");
     tcp.Disengage();
 }