Exemplo n.º 1
0
        public SequencePage(Panel tempPanel, String procedureName, PDU pdu, Procedure tempProcedure, StreamSocket tempSocket)
        {
            newSocket = tempSocket;
            localProcedure = tempProcedure;
            procedure = procedureName;
            tempPDU = pdu;
            panel2 = tempPanel;
            this.InitializeComponent();
            procedureTextBlock.Text = procedureName;

            loadSequences();
        }
Exemplo n.º 2
0
 public PDU pduCreator(CommandMessageID IDmsg, string tempDescription, JObject obj)
 {
     PDU pdu = new PDU()
     {
         MessageID = (int)IDmsg,
         MessageDescription = tempDescription,
         MessageType = "Command",
         Source = "Demo.Client",
         Data = obj
     };
     return pdu;
 }
Exemplo n.º 3
0
        public MainPage()
        {
            this.InitializeComponent();

            PDU pdu = new PDU()
            {
                MessageID = (int)CommandMessageID.LoadSequenceFile,
                MessageDescription = "Server Please, load the sequencefile I specified as part of this message.",
                MessageType = "Command",
                Source = "Demo.Client",
                Data = new JObject()
            };
            pdu.Data.SequenceFileName = "loltest.seqfile";
            
        }
Exemplo n.º 4
0
        async private void recieveData()
        {
            StreamSocketListener listener = new StreamSocketListener();
            DataReader dr = new DataReader(socket.InputStream);
            dr.InputStreamOptions = InputStreamOptions.Partial;
            string msg = null;
            var count = await dr.LoadAsync(8192);

            if (count > 0)
                msg = dr.ReadString(count);

            dr.DetachStream();
            dr.Dispose();

            try
            {
                pdu2 = new PDU(msg);
                ListOfProcedures temp = pdu2.Data.ToObject(typeof(ListOfProcedures));
                foreach (Procedure pro in temp.ProcedureList)
                {
                    _kakecollection.Add(pro);
                }
            }
            catch (Exception e) { recievedMessage.Text = "Failed to cast incomming message to usable type: PDU"; }
        }
Exemplo n.º 5
0
 async private void loltest_Click(object sender, RoutedEventArgs e)
 {
     PDU pdu2 = new PDU()
     {
         MessageID = (int)CommandMessageID.StartExecution,
         MessageDescription = "Server Please, load the sequencefile I specified as part of this message.",
         MessageType = "Command",
         Source = "Demo.Client",
         Data = new JObject()
     };
     pdu2.Data.SequenceFileName = "loltest.seq";
     StreamWriter datawr = new StreamWriter(tcpSocket.OutputStream.AsStreamForWrite(), System.Text.Encoding.UTF8);
     char [] trimmer = new char[1];
     trimmer[0] = '.';
     datawr.Flush();
     datawr.Write(pdu2.ToJson());
     recievedTextBox.Text = pdu2.ToJson();
     datawr.Flush();
 }
Exemplo n.º 6
0
        private void Run_Click(object sender, RoutedEventArgs e)
        {
            PDU runSteps = new PDU()
            {
                MessageID = (int)CommandMessageID.StartExecution,
                MessageDescription = "Server please, start execution",
                MessageType = "Command",
                Source = "Demo.Client",
                Data = new JObject()
            };

        }
Exemplo n.º 7
0
        async private void recieveData()
        {
            StreamSocketListener listener = new StreamSocketListener();
            DataReader dr = new DataReader(newSocket.InputStream);
            dr.InputStreamOptions = InputStreamOptions.Partial;
            string msg = null;
            try
            {
                var count = await dr.LoadAsync(8192);
                if (count > 0)
                    msg = dr.ReadString(count);
            }
            catch { }
            dr.DetachStream();
            dr.Dispose();

            try
            {
                pdu2 = new PDU(msg);
                Execution temp = pdu2.Data.ToObject(typeof(Execution));
                _stepCollection.Clear();
                foreach (Step steps in temp.CurrentSequence.StepList)
                {
                    _stepCollection.Add(steps);
                }
            }

            catch (Exception e) { }
            Execution temp2 = pdu2.Data.ToObject(typeof(Execution));
            if (temp2.State == Execution.ExecutionStates.FINISHED || temp2.State == Execution.ExecutionStates.TERMINATED)
            {
                PDU pdu3 = new PDU(){
                    MessageID = (int)CommandMessageID.ResetTS,
                    MessageDescription = "Server please, reset TS",
                    MessageType = "Command",
                    Source = "Demo.Client",
                    Data = new JObject()
                };
                sendData(pdu3);
            } else { recieveData(); }
            
        }
Exemplo n.º 8
0
        private async void sendData(PDU k)
        {
            var dr = new DataWriter(newSocket.OutputStream);
            
            //var len = dr.MeasureString(pdu.ToJson());
            String message = k.ToJson();
            //dr.WriteInt32((int)len);
            dr.WriteString(k.ToJson());
            var ret = await dr.StoreAsync();

            recieveData();
            dr.DetachStream();

        }
Exemplo n.º 9
0
        public async void nowConnecting()
        {
            bool connected = false;
            int remotePort = 1337;
            while (!connected)
            {

                try
                {
                    EndpointPair connection = new EndpointPair(localHost, remotePort.ToString(), remoteHost, socketString);
                    await socket.ConnectAsync(connection);
                    connected = true;
                    
                    recievedMessage.Text = "Welcome, you are now connected";
                }
                catch (Exception ex)
                {

                    connected = false;
                    remotePort++;
                    recievedMessage.Text = "Changed to free port: " + remotePort;

                }
            }
            
            PDU authenticatePDU = new PDU()
            {
                MessageID = (int)CommandMessageID.LoginAttempt,
                MessageDescription = "Server Please, check and authenticate this user",
                MessageType = "Command",
                Source = "Demo.Client",
                Data = JObject.FromObject(_user)
            };
            sendData(authenticatePDU);
        }
Exemplo n.º 10
0
 void listener_ConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args)
 {
     throw new NotImplementedException();
     dr2 = new DataReader(socket.InputStream);
     PDU pdu2 = new PDU(dr2.ToString());
     Procedure temp = pdu2.Data.ToObject(typeof(Procedure));
     _kakecollection.Add(new kakeclass { Name = "123", Description = temp.Description, Date = temp.Date });
 }
Exemplo n.º 11
0
        async private void recieveData()
        {
            StreamSocketListener listener = new StreamSocketListener();
            DataReader dr = new DataReader(socket.InputStream);
            dr.InputStreamOptions = InputStreamOptions.Partial;
            string msg = null;
            var count = await dr.LoadAsync(4096);

            if (count > 0)
                msg = dr.ReadString(count);
            recievedMessage.Text = msg;

            dr.DetachStream();
            dr.Dispose();

            try
            {
                PDU pdu2 = new PDU(msg);
                Procedure temp = pdu2.Data.ToObject(typeof(Procedure));
                _kakecollection.Add(new kakeclass { Name = temp.Name, Description = temp.Description, Date = temp.Date });
            }
            catch (Exception e) { recievedMessage.Text = "Failed to cast incomming message to usable type: PDU"; }

            try
            {
                listener.ConnectionReceived += listener_ConnectionReceived;
                await listener.BindServiceNameAsync(socketString);
                

            }
            catch (Exception e) { recievedMessage.Text = e.ToString(); }

        }