public override bool SearchTrip(UserNodeCore context, QueryBuilder qb) { Command command = new SearchTripCommand(qb); context.ServiceProxy.HandleDarPoolingRequest(command); return(true); }
public override bool InsertTrip(UserNodeCore context, Communication.Trip trip) { Command command = new InsertTripCommand(trip); context.ServiceProxy.HandleDarPoolingRequest(command); // This command does not change state return true; }
public override bool RegisterUser(UserNodeCore context, User user, string serviceNodeAddress, string callbackAddress) { try { ClientCallback callback = new ClientCallback(context); // First of all, set up the connection EndpointAddress endPointAddress = new EndpointAddress(serviceNodeAddress); WSDualHttpBinding binding = new WSDualHttpBinding(); binding.ClientBaseAddress = new Uri(callbackAddress); DuplexChannelFactory <IDarPooling> factory = new DuplexChannelFactory <IDarPooling>( callback, binding, endPointAddress); context.ServiceProxy = factory.CreateChannel(); } catch { context.ServiceProxy = null; return(false); } Command c = new Communication.RegisterUserCommand(user); try { context.ServiceProxy.HandleDarPoolingRequest(c); } catch (TimeoutException e) { context.ServiceProxy = null; throw e; } return(true); }
public override bool InsertTrip(UserNodeCore context, Communication.Trip trip) { Command command = new InsertTripCommand(trip); context.ServiceProxy.HandleDarPoolingRequest(command); // This command does not change state return(true); }
public override bool Unjoin(UserNodeCore context) { Command command = new UnjoinCommand(context.UserNode.User.UserName); context.ServiceProxy.HandleDarPoolingRequest(command); context.State = new UnjointState(); context.ServiceProxy = null; return true; }
public override bool Unjoin(UserNodeCore context) { Command command = new UnjoinCommand(context.UserNode.User.UserName); context.ServiceProxy.HandleDarPoolingRequest(command); context.State = new UnjointState(); context.ServiceProxy = null; return(true); }
static void InitializeClient() { CreateUsers(); /* Clients */ UserNode catania1UN = new UserNode(userList.ElementAt(0), "Catania"); UserNode catania2UN = new UserNode(userList.ElementAt(1), "Catania"); //UserNode milano1UN = new UserNode("4nT0", "Milano"); UserNodeCore catania1 = new UserNodeCore(catania1UN); UserNodeCore catania2 = new UserNodeCore(catania2UN); //UserNodeCore milano1 = new UserNodeCore(milano1UN); UserNodeCore[] userNodes = new UserNodeCore[] { catania1, catania2 }; uncList.AddRange(userNodes); }
/* Callback */ static void StartCommunication() { Console.WriteLine("***** Test HTTP CALLBACK Client *****"); Console.WriteLine("\n\nPress a key to start the communication"); Console.ReadLine(); User testUser1 = userList.ElementAt(0); UserNodeCore testClient1 = uncList.ElementAt(0); LoginUserCommand login = new LoginUserCommand(testUser1.UserName, testUser1.Password); testClient1.ConnectToService(login); Console.WriteLine("\n\n\nClient is now ready to perform some other task"); User testUser2 = userList.ElementAt(1); UserNodeCore testClient2 = uncList.ElementAt(1); Console.WriteLine("\n\n\nProvo a connettermi...."); testClient2.ConnectToService(login); Console.WriteLine("\n\n\nConnessione effettuata!"); }
public override bool Join(UserNodeCore context, string username, string password, string serviceNodeAddress, string callbackAddress) { try { ClientCallback callback = new ClientCallback(context); // First of all, set up the connection EndpointAddress endPointAddress = new EndpointAddress(serviceNodeAddress); WSDualHttpBinding binding = new WSDualHttpBinding(); binding.ClientBaseAddress = new Uri(callbackAddress); DuplexChannelFactory <IDarPooling> factory = new DuplexChannelFactory <IDarPooling>( callback, binding, endPointAddress); context.ServiceProxy = factory.CreateChannel(); } catch { context.ServiceProxy = null; return(false); } // Now, hopefully you have a working ServiceProxy. string passwordHash = Communication.Tools.HashString(password); Command c = new JoinCommand(context.UserNode, username, passwordHash); try { context.ServiceProxy.HandleDarPoolingRequest(c); } catch (TimeoutException e) { context.ServiceProxy = null; throw e; } // Finally, if Join is NOT successfull, remove reference (UserNodeCore.onResultReceive) return(true); }
public override bool RegisterUser(UserNodeCore context, User user, string serviceNodeAddress, string callbackAddress) { try { ClientCallback callback = new ClientCallback(context); // First of all, set up the connection EndpointAddress endPointAddress = new EndpointAddress(serviceNodeAddress); WSDualHttpBinding binding = new WSDualHttpBinding(); binding.ClientBaseAddress = new Uri(callbackAddress); DuplexChannelFactory<IDarPooling> factory = new DuplexChannelFactory<IDarPooling>( callback, binding, endPointAddress); context.ServiceProxy = factory.CreateChannel(); } catch { context.ServiceProxy = null; return false; } Command c = new Communication.RegisterUserCommand(user); try { context.ServiceProxy.HandleDarPoolingRequest(c); } catch (TimeoutException e) { context.ServiceProxy = null; throw e; } return true; }
public virtual bool Unjoin(UserNodeCore context) { return false; }
public override bool Join(UserNodeCore context, string username, string password, string serviceNodeAddress, string callbackAddress) { try { ClientCallback callback = new ClientCallback(context); // First of all, set up the connection EndpointAddress endPointAddress = new EndpointAddress(serviceNodeAddress); WSDualHttpBinding binding = new WSDualHttpBinding(); binding.ClientBaseAddress = new Uri(callbackAddress); DuplexChannelFactory<IDarPooling> factory = new DuplexChannelFactory<IDarPooling>( callback, binding, endPointAddress); context.ServiceProxy = factory.CreateChannel(); } catch { context.ServiceProxy = null; return false; } // Now, hopefully you have a working ServiceProxy. string passwordHash = Communication.Tools.HashString(password); Command c = new JoinCommand(context.UserNode, username, passwordHash); try { context.ServiceProxy.HandleDarPoolingRequest(c); } catch (TimeoutException e) { context.ServiceProxy = null; throw e; } // Finally, if Join is NOT successfull, remove reference (UserNodeCore.onResultReceive) return true; }
public virtual bool RegisterUser(UserNodeCore context, User user, string serviceNodeAddress, string callbackAddress) { return(false); }
public virtual bool SearchTrip(UserNodeCore context, QueryBuilder qb) { return false; }
public ClientCallback(UserNodeCore parent) { this.parent = parent; }
public virtual bool Join(UserNodeCore context, string username, string password, string serviceNodeAddress, string callbackAddress) { return(false); }
public virtual bool Join(UserNodeCore context, string username, string password, string serviceNodeAddress, string callbackAddress) { return false; }
public virtual bool Unjoin(UserNodeCore context) { return(false); }
public virtual bool InsertTrip(UserNodeCore context, Communication.Trip trip) { return(false); }
public virtual bool SearchTrip(UserNodeCore context, QueryBuilder qb) { return(false); }
public override bool SearchTrip(UserNodeCore context, QueryBuilder qb) { Command command = new SearchTripCommand(qb); context.ServiceProxy.HandleDarPoolingRequest(command); return true; }
public virtual bool InsertTrip(UserNodeCore context, Communication.Trip trip) { return false; }
// Console-Client, used for debug purposes public static void Main() { UserNodeCore user = new UserNodeCore(new UserNode("prova")); Console.WriteLine("***** DarPooling Client Console Testing *****\n\n"); User dummy = new User { UserName = "******", Password = "******", Name = "Daniele", UserSex = User.Sex.m, BirthDate = new DateTime(1986, 04, 08), Email = "*****@*****.**", Smoker = false, SignupDate = DateTime.Now.AddDays(-30), Whereabouts = "" }; Trip trip1 = new Trip { Owner = "daniele@http://localhost:1111/Milano", DepartureName = "Aci Trezza", DepartureDateTime = new DateTime(2010, 7, 30, 8, 0, 0), ArrivalName = "Milano", ArrivalDateTime = new DateTime(2010, 7, 30, 10, 30, 0), Smoke = false, Music = false, Cost = 10, FreeSits = 4, Notes = "none", Modifiable = false }; QueryBuilder query1 = new QueryBuilder { Owner = "daniele@http://localhost:1111/Milano", DepartureName = "Aci Trezza", /* DepartureDateTime = new DateTime(2010, 7, 30, 8, 0, 0), ArrivalName = "Milano", ArrivalDateTime = new DateTime(2010, 7, 30, 10, 30, 0), Smoke = false, Music = false, Cost = 10, FreeSits = 4, Notes = "none", Modifiable = false */ }; /* // Case 4: LoginForward Console.ReadLine(); Console.WriteLine("Press a key... (Forward expected)"); Console.ReadLine(); Console.WriteLine("Key pressed!"); user.Join("Shaoran@http://localhost:1111/Milano", "shaoran", "http://*****:*****@http://localhost:1111/Milano"); TestCommands(unjoin); Console.ReadLine(); Console.WriteLine("Press a key... (Register)"); Console.ReadLine(); RegisterUserCommand register = new RegisterUserCommand(dummy); TestCommands(register); //TestCommands(register); */ string city; int range; while (true) { EndpointAddress endPointAddress = new EndpointAddress("http://localhost:1155/Catania"); BasicHttpBinding binding = new BasicHttpBinding(); ChannelFactory<IDarPoolingMobile> factory = new ChannelFactory<IDarPoolingMobile>( binding, endPointAddress); IDarPoolingMobile serviceProxy = factory.CreateChannel(); string res = serviceProxy.HandleDarPoolingMobileRequest(new UnjoinCommand("pippo")); Console.WriteLine("Got : {0}", res); Console.WriteLine("I per insert, S per search, R per search-range:"); string instruction = Console.ReadLine(); switch(instruction) { case "i": //Console.ReadLine(); Console.WriteLine("Insert departure city... (Insert Trip)"); city = Console.ReadLine(); trip1.DepartureName = city; InsertTripCommand insert = new InsertTripCommand(trip1); TestCommands(insert); break; case "s": Console.WriteLine("Insert departure city... (Search Trip)"); city = Console.ReadLine(); query1.DepartureName = city; query1.Range = 0; SearchTripCommand search = new SearchTripCommand(query1); TestCommands(search); break; case "r": Console.WriteLine("Insert departure city... (Search Trip)"); city = Console.ReadLine(); query1.DepartureName = city; Console.WriteLine("Insert search Range... (Search Trip)"); range = Convert.ToInt32(Console.ReadLine()); query1.Range = range; SearchTripCommand search2 = new SearchTripCommand(query1); TestCommands(search2); break; default: break; } //Console.ReadLine(); } }
public virtual bool RegisterUser(UserNodeCore context, User user, string serviceNodeAddress, string callbackAddress) { return false; }
// Console-Client, used for debug purposes public static void Main() { UserNodeCore user = new UserNodeCore(new UserNode("prova")); Console.WriteLine("***** DarPooling Client Console Testing *****\n\n"); User dummy = new User { UserName = "******", Password = "******", Name = "Daniele", UserSex = User.Sex.m, BirthDate = new DateTime(1986, 04, 08), Email = "*****@*****.**", Smoker = false, SignupDate = DateTime.Now.AddDays(-30), Whereabouts = "" }; Trip trip1 = new Trip { Owner = "daniele@http://localhost:1111/Milano", DepartureName = "Aci Trezza", DepartureDateTime = new DateTime(2010, 7, 30, 8, 0, 0), ArrivalName = "Milano", ArrivalDateTime = new DateTime(2010, 7, 30, 10, 30, 0), Smoke = false, Music = false, Cost = 10, FreeSits = 4, Notes = "none", Modifiable = false }; QueryBuilder query1 = new QueryBuilder { Owner = "daniele@http://localhost:1111/Milano", DepartureName = "Aci Trezza", /* * DepartureDateTime = new DateTime(2010, 7, 30, 8, 0, 0), * ArrivalName = "Milano", * ArrivalDateTime = new DateTime(2010, 7, 30, 10, 30, 0), * Smoke = false, * Music = false, * Cost = 10, * FreeSits = 4, * Notes = "none", * Modifiable = false */ }; /* * // Case 4: LoginForward * Console.ReadLine(); * Console.WriteLine("Press a key... (Forward expected)"); * Console.ReadLine(); * Console.WriteLine("Key pressed!"); * user.Join("Shaoran@http://localhost:1111/Milano", "shaoran", "http://*****:*****@http://localhost:1111/Milano"); * TestCommands(unjoin); * * * Console.ReadLine(); * Console.WriteLine("Press a key... (Register)"); * Console.ReadLine(); * RegisterUserCommand register = new RegisterUserCommand(dummy); * TestCommands(register); * //TestCommands(register); */ string city; int range; while (true) { EndpointAddress endPointAddress = new EndpointAddress("http://localhost:1155/Catania"); BasicHttpBinding binding = new BasicHttpBinding(); ChannelFactory <IDarPoolingMobile> factory = new ChannelFactory <IDarPoolingMobile>( binding, endPointAddress); IDarPoolingMobile serviceProxy = factory.CreateChannel(); string res = serviceProxy.HandleDarPoolingMobileRequest(new UnjoinCommand("pippo")); Console.WriteLine("Got : {0}", res); Console.WriteLine("I per insert, S per search, R per search-range:"); string instruction = Console.ReadLine(); switch (instruction) { case "i": //Console.ReadLine(); Console.WriteLine("Insert departure city... (Insert Trip)"); city = Console.ReadLine(); trip1.DepartureName = city; InsertTripCommand insert = new InsertTripCommand(trip1); TestCommands(insert); break; case "s": Console.WriteLine("Insert departure city... (Search Trip)"); city = Console.ReadLine(); query1.DepartureName = city; query1.Range = 0; SearchTripCommand search = new SearchTripCommand(query1); TestCommands(search); break; case "r": Console.WriteLine("Insert departure city... (Search Trip)"); city = Console.ReadLine(); query1.DepartureName = city; Console.WriteLine("Insert search Range... (Search Trip)"); range = Convert.ToInt32(Console.ReadLine()); query1.Range = range; SearchTripCommand search2 = new SearchTripCommand(query1); TestCommands(search2); break; default: break; } //Console.ReadLine(); } }