Esempio n. 1
0
        private void CallRequest(CommandLibrary.Command command, Socket handler)
        {
            Connection conn = new Connection();

            conn.bandwidth         = command.bandwidth;
            conn.connectionId      = connectionList.Count;
            conn.domainOfRequester = command.domainOfRequestingClient;
            conn.startId           = command.startClientId;
            conn.endId             = command.endClientId;
            connectionList.Add(conn);

            CommandLibrary.Command directoryRequest = new CommandLibrary.Command("Directory Request");
            directoryRequest.sourceId                 = nccId;
            directoryRequest.destinationId            = self.ReturnName() + ":PC";
            directoryRequest.endClientId              = command.endClientId;
            directoryRequest.startClientId            = command.startClientId;
            directoryRequest.domainOfRequestingClient = command.domainOfRequestingClient;
            directoryRequest.bandwidth                = command.bandwidth;
            using (var stream = new NetworkStream(handler))
            {
                BinaryFormatter bformatter = new BinaryFormatter();
                bformatter.Serialize(stream, directoryRequest);
                stream.Flush();
                stream.Close();
            }
            self.mainWindow.Invoke(new Action(() => self.Logs += DateTime.UtcNow.ToString("HH:mm:ss.fff") + $" >> NCC >> 'Directory Request ({directoryRequest.endClientId})' sent to {directoryRequest.destinationId}" + Environment.NewLine));
        }
Esempio n. 2
0
 private void DirectoryRequest(CommandLibrary.Command command, Socket handler)
 {
     self.mainWindow.Invoke(new Action(() => self.Logs += DateTime.UtcNow.ToString("HH:mm:ss.fff") + " >> PC >> Translating destination address..." + Environment.NewLine));
     CommandLibrary.Command callConfirmed = new CommandLibrary.Command("Directory Request confirmed");
     callConfirmed.sourceId      = pcId;
     callConfirmed.destinationId = self.ReturnName() + ":NCC";
     callConfirmed.endClientId   = command.endClientId;
     callConfirmed.startClientId = command.startClientId;
     callConfirmed.bandwidth     = command.bandwidth;
     clientsAndDomains.TryGetValue(command.endClientId, out callConfirmed.domainOfRequestedClient);
     callConfirmed.domainOfRequestingClient = command.domainOfRequestingClient;
     using (var stream = new NetworkStream(handler))
     {
         BinaryFormatter bformatter = new BinaryFormatter();
         bformatter.Serialize(stream, callConfirmed);
         stream.Flush();
         stream.Close();
     }
 }