Esempio n. 1
0
        /// <summary>
        /// Injects data read from a a peripheral device, in response to a <see cref="StartDevice"/> event.
        /// </summary>
        /// <param name="device">The name of the device: <see cref="DEV_KEYBOARD"/>, <see cref="DEV_BARCODE"/> or <see cref="DEV_MAGSTRIPE"/>.</param>
        /// <param name="data">The data read from the device</param>
        public void DeviceData(string device, string data)
        {
            var message = new DeviceDataMessage()
            {
                Device = device,
                Data   = data
            };

            SendJsonRequest(message);
        }
Esempio n. 2
0
    public void GotConfig()
    {
        Destroy(_waiting);
        Destroy(_shadow);
        _waiting = UIHelper.CenterInParent(Instantiate(DataDiplayScreen), MainCanvas.gameObject);
        _waiting.transform.GetComponent <StatusInfoDisplay>().SetupDisplay(_config.GetMyNetworkConfig().Address, _config.GetMyNetworkConfig().Port, _config.GetTestCases().Count);
        _waiting.transform.Find("Button").gameObject.GetComponent <Button>().onClick.AddListener(delegate { transform.root.GetComponent <ButtonBehaviour>().HideConfig(); });
        _waiting.transform.Find("Button").gameObject.SetActive(false);
        var dev = new DeviceDataMessage(new DeviceIdentification(_deviceClass));

        _config.DeviceString = dev.DeviceIdentification.DevId;
        MyNetworkManager.singleton.client.Send(MyMsgType.DeviceData, dev);
    }
Esempio n. 3
0
    public void CheckDevice(NetworkMessage message)
    {
        DeviceDataMessage    msg = message.ReadMessage <DeviceDataMessage>();
        DeviceIdentification deviceIdentification = msg.DeviceIdentification;
        var db         = MongoDBConnector.GetInstance().GetDatabase();
        var collection = db.GetCollection <BsonDocument>("Devices");
        var results    = collection.Find(new BsonDocument {
            { "DevId", deviceIdentification.DevId }
        }).ToList();
        int addr = -1;

        if (results.Count > 0)
        {
            foreach (var result in results)
            {
                if (result["ScreenWidth"].AsInt32 == deviceIdentification.ScreenWidth &&
                    result["ScreenHeight"].AsInt32 == deviceIdentification.ScreenHeight &&
                    result["DeviceClass"].AsInt32 == (int)deviceIdentification.DeviceClass)
                {
                    addr = result["id"].AsInt32;
                }
            }
        }
        if (addr == -1)
        {
            var value = collection.Find(new BsonDocument()).Sort(new BsonDocument {
                { "id", -1 }
            }).Limit(1).Project(Builders <BsonDocument> .Projection.Exclude("_id").Include("id"));
            int maxid;
            if (value.Count() > 0)
            {
                maxid = JsonUtility.FromJson <int>(value.ToJson());
            }
            else
            {
                maxid = 0;
            }
            var document = new BsonDocument
            {
                { "id", maxid + 1 },
                { "DevId", deviceIdentification.DevId },
                { "ScreenWidth", deviceIdentification.ScreenWidth },
                { "ScreenHeight", deviceIdentification.ScreenHeight },
                { "DeviceClass", deviceIdentification.DeviceClass }
            };
            collection.InsertOne(document);
            addr = maxid;
        }
        NetworkServer.SendToClient(message.conn.connectionId, MyMsgType.DeviceId, new IntegerMessage(addr));
    }