コード例 #1
0
ファイル: Program.cs プロジェクト: hgabor47/bms_windowslist
 static void NewInputFrame(BabylonMS.BMSEventSessionParameter session) //newinput frame or continuous
 {
     try
     {
         lista();
         bms.TransferPacket(session.writer, outputpack, false);
         outputpack.Clear();
     }
     catch (Exception) { };
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: hgabor47/bms_imagebuffer
        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) {
            };
        }