示例#1
0
        public Client()
        {
            message = new string[4] {
                " ", " ", " ", " "
            };

            vr       = new VRConnector();
            commands = new VRCommands(vr);
            vr.getClientInfo();

            sessionList = commands.refreshConnection(vr.readObject());
            commands.connectClient(sessionList);
            vr.Destination = vr.readObject().SelectToken("data").SelectToken("id").ToString();
            Thread readerThread = new Thread(reading);

            readerThread.Start();
            commands.route();
            commands.createPanel("hud");
            commands.find("Camera");
            commands.createPanel("chat");

            spp = new FakeData();


            Thread serverConnection = new Thread(serverReader);

            serverConnection.Start();


            Thread.Sleep(200);

            commands.addRoad(routeUuid);
            commands.follow(routeUuid, HUDUuid);
            commands.update(HUDUuid, cameraUuid);
            commands.update(HUDUuid, chatUuid);

            clientStart();
        }
示例#2
0
        public void reading()
        {
            while (true)
            {
                Thread.Sleep(1);
                try
                {
                    JObject Json = vr.readObject();
                    //Console.WriteLine(Json);
                    JToken token = Json.SelectToken("data").SelectToken("data");
                    string id    = token.SelectToken("id").ToString();
                    switch (id)
                    {
                    case "session/list": commands.connectClient(token.SelectToken("data").ToObject <JArray>()); break;

                    case "tunnel/create": vr.Destination = vr.readObject().SelectToken("data").SelectToken("id").ToString(); break;

                    case "route/add": routeUuid = token.SelectToken("data").SelectToken("uuid").ToString(); break;

                    case "scene/node/find": nodeFound(token.SelectToken("data").ToObject <JArray>()); break;

                    case "scene/node/add": nodeAdded(token.SelectToken("data")); break;

                    case "scene/skybox/settime": break;

                    case "nothingHere": break;

                    default: break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
            }
        }
示例#3
0
        public Client(NetworkStream stream)
        {
            this.stream = stream;
            message     = new string[4] {
                " ", " ", " ", " "
            };

            vr       = new VRConnector();
            commands = new VRCommands(vr);
            vr.getClientInfo();

            sessionList = commands.refreshConnection(vr.readObject());
            commands.connectClient(sessionList);
            vr.Destination = vr.readObject().SelectToken("data").SelectToken("id").ToString();
            Thread readerThread = new Thread(reading);

            readerThread.Start();
            commands.route();
            commands.bike();
            commands.createPanel("hud");
            commands.find("Camera");
            commands.createPanel("chat");
            //string[] ports = SerialPort.GetPortNames();
            //for (int i = 0; i < ports.Length; i++)
            //{
            //    try
            //    {
            //        spp = new SerialPortProgram(ports[i]);

            //    }
            //    catch (Exception e){
            //        Console.WriteLine(e.StackTrace);
            //    }
            //}
            spp = new FakeData();


            Thread serverConnection = new Thread(serverReader);

            serverConnection.Start();


            Thread.Sleep(400);


            commands.addRoad(routeUuid);
            commands.follow(routeUuid, bikeUuid);
            float[] offset = new float[3] {
                0, 5.75f, -1.5f
            };
            commands.update(bikeUuid, HUDUuid, offset);
            offset = new float[3] {
                1, 4.9f, -3f
            };
            commands.update(bikeUuid, cameraUuid, offset);
            offset = new float[3] {
                2, 5.75f, -1.5f
            };
            commands.update(bikeUuid, chatUuid, offset);
            commands.chat(message, chatUuid);
            clientStart();
        }