static void Main(string[] args) { try { // Instantiate a new space repository, and add two seperate gates. SpaceRepository repository = new SpaceRepository(); repository.AddGate("tcp://127.0.0.1:123?KEEP"); repository.AddGate("tcp://127.0.0.1:124?KEEP"); // Create a new fifo based space, and insert the ping. repository.AddSpace("pingpong", new SequentialSpace()); repository.Put("pingpong", "ping", 0); // Create two seperate remotespaces and agents. // The agents use their own private remotespace. RemoteSpace remotespace1 = new RemoteSpace("tcp://127.0.0.1:123/pingpong?KEEP"); PingPong a1 = new PingPong("ping", "pong", remotespace1); RemoteSpace remotespace2 = new RemoteSpace("tcp://127.0.0.1:124/pingpong?KEEP"); PingPong a2 = new PingPong("pong", "ping", remotespace2); // Start the agents a1.Start(); a2.Start(); Console.Read(); } catch (Exception e) { throw e; } }
public ConferenceWindow(string username, string conferenceName, string password, RemoteSpace conferenceRequests, RemoteSpace LoginSpace) //For host { DataContext = this; this.Password = password; this.username = username; this.ConferenceName = conferenceName; this.LoginSpace = LoginSpace; dlg.FileName = "Presentation"; // Default file name dlg.DefaultExt = ".pdf"; // Default file extension dlg.Filter = "PDF documents (.pdf)|*.pdf"; // Filter files by extension InitializeComponent(); SpaceRepository spaceRepository = new SpaceRepository(); this.TxtToSend = new TextRange(SendField.Document.ContentStart, SendField.Document.ContentEnd); this.MsgList = new ObservableCollection <string>(); this.conference = new ConferenceInitializer(username, conferenceName, MsgList, spaceRepository, this); this.ConferenceRequests = conferenceRequests; this.Loaded += MainWindow_Loaded; Closed += OnClose_Host; SendField.KeyUp += SendField_KeyUp; this.SizeChanged += Resize; SendButton.Click += SendButton_Click; GoBackwards.Click += GoBackwards_Click; GoForward.Click += GoForwad_Click; OpenPresentaion.MouseDown += OpenPresentaion_Click; }
static void Main(string[] args) { if (args.Length == 1) { if (args[0] == "producer") { // Create a new space repository, and add a new gate to it. // The gate is using CONN, meaning the connection is NOT persistent. SpaceRepository repository = new SpaceRepository(); repository.AddGate("tcp://127.0.0.1:123?CONN"); // Add a new fifo based space repository.AddSpace("fridge", new SequentialSpace()); // Create a new agent, and let the agent use the local tuple space instead of a networked remotespace. AgentBase alice = new Producer("Alice", repository.GetSpace("fridge")); alice.Start(); return; } else if (args[0] == "consumer") { // The consumers use a remote space to access the space repository. ISpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/fridge?CONN"); List <AgentBase> agents = new List <AgentBase>(); agents.Add(new FoodConsumer("Bob", remotespace)); agents.Add(new FoodConsumer("Charlie", remotespace)); agents.Add(new DrugConsumer("Dave", remotespace)); agents.ForEach(a => a.Start()); Console.Read(); return; } } Console.WriteLine("Please specify [producer|consumer]"); Console.Read(); }
public static IEnumerable <ITuple> GetSubscribersInALobby(string lobbyUrl) { RemoteSpace lobbySpace = new RemoteSpace(lobbyUrl); IEnumerable <ITuple> subscriberTuple = lobbySpace.QueryAll("player", typeof(int), typeof(string)); return(subscriberTuple); }
public static bool SubscribeForLobby(string lobbyUrl) { string username = Connection.LocalPlayer.Name; int user_id = (int)Connection.LocalPlayer.Id; RemoteSpace lobbySpace = new RemoteSpace(lobbyUrl); lobbySpace.Get("lobby_lock"); ITuple playerTuple = lobbySpace.GetP("player", 0, "No user"); //Means that that there is no slots left in the lobby if (playerTuple == null) { lobbySpace.Put("lobby_lock"); return(false); } // Get lobby info (wasn't given with responsee) var lobbyTuple = Connection.GlobalSpace.Query("existingLobby", typeof(string), typeof(string), lobbyUrl); var ownerName = (string)lobbyTuple[2]; var ownerId = GetPlayerId(ownerName); Connection.Lobby = new Lobby(); Connection.Lobby.Space = lobbySpace; Connection.Lobby.Url = lobbyUrl; Connection.Lobby.Owner = new Player(ownerId, ownerName); Connection.Lobby.Id = (string)lobbyTuple[1]; lobbySpace.Put("player", user_id, username); lobbySpace.Put("lobby_lock"); return(true); }
/// <summary> /// Fetches information about all existing lobbies /// May perform many server calls /// </summary> public static List <LobbyInfo> GetLobbies() { var lobbies = new List <LobbyInfo>(); var lobbyTuples = Connection.GlobalSpace.QueryAll("existingLobby", typeof(string), typeof(string), typeof(string)); foreach (var lobbyTuple in lobbyTuples) { // Setup basic info LobbyInfo lobby; lobby.Id = (string)lobbyTuple[1]; lobby.OwnerName = (string)lobbyTuple[2]; lobby.Url = (string)lobbyTuple[3]; // Connect to lobby space, and fetch players // Note: It's super slow to establish this connection everytime RemoteSpace lobbySpace = new RemoteSpace(lobby.Url); lobby.NumPlayers = 0; var playerTuples = lobbySpace.QueryAll("player", typeof(int), typeof(string)); foreach (var playerTuple in playerTuples) { // Check that slot is filled if ((int)playerTuple[1] > 1 && (string)playerTuple[2] != "No user") { lobby.NumPlayers++; } } lobbies.Add(lobby); } return(lobbies); }
private void MovePageContent(Dictionary <string, string> pathMap) { foreach (string space in Utils.GetPersistedSpaces()) { if ((_spacesToConvert.Count > 0) && (!_spacesToConvert.Contains(space.ToLower()))) { continue; } RemoteSpace spaceInfo = _confluenceService.GetSpace(space); foreach (string p in Utils.GetPersistedPagesInSpace(space)) { ACConverterPageInfo pageInfo = Utils.RestorePageInfo(space, p); if (pageInfo != null) { MovePageContent(pathMap, pageInfo); if (pageInfo.ConfluencePage.id == spaceInfo.homePage) { //Set content of the MT space root page after the homepage is processed. string content = "{{" + string.Format("wiki.page(wiki.getpage({0}).path);", pageInfo.DekiPageId) + "}}"; CreateDekiPage(_dekiPlug, pageInfo.SpaceRootPath, spaceInfo.name, null, content); } } } } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Please specify your name"); return; } // Instantiate a new Space repository. SpaceRepository repository = new SpaceRepository(); // Add a gate, such that we can connect to it. repository.AddGate("tcp://127.0.0.1:123?CONN"); // Add a new Fifo based space. repository.AddSpace("dtu", new SequentialSpace()); // Insert a tuple with a message. repository.Put("dtu", "Hello student!"); // Instantiate a remotespace (a networked space) thereby connecting to the spacerepository. ISpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/dtu?CONN"); // Instantiate a new agent, assign the tuple space and start it. AgentBase student = new Student(args[0], remotespace); student.Start(); // Wait and retrieve the message from the agent. ITuple tuple = repository.Get("dtu", typeof(string), typeof(string)); // Print the contents to the console. Console.WriteLine(string.Format("{0}, you are attending course {1}", tuple[0], tuple[1])); Console.Read(); }
public Page getSpaceHomepage(Space spaceSummary) { checkCredentials(); RemoteSpace spaceDetail = confluence.getSpace(credentials, spaceSummary.Key); RemotePage page = confluence.getPage(credentials, spaceDetail.homePage); return(new Page(page)); }
public Chat(string name, string uri, string conferenceName, ObservableCollection<string> dataSource) { //For client LoggedInUser = name; DataSource = dataSource; string remoteName = NameHashingTool.GenerateUniqueRemoteSpaceUri(uri, conferenceName); ChatSpace = new RemoteSpace(remoteName); }
public void CreateSpace(string name) { RemoteSpace space = new RemoteSpace(); space.name = name; space.key = name; space.description = name; m_soapService.addSpace(m_soapAuthToken, space); }
public TupleConnection(string ip, string port, string space, Action <string, string, string, string, bool, string> insertMessage) { _ip = ip; _port = port; _space = space; _remotespace = new RemoteSpace($"tcp://{ip}:{port}/{space}?KEEP"); _insertMessage = insertMessage; ContinueToCheckOnline = false; ContinueToCheckGroupMessage = false; }
public Chat(string name, string uri, string conferenceName, IRepository chatRepo, ObservableCollection<string> dataSource) { //For host LoggedInUser = name; chatRepo.AddSpace(NameHashingTool.GenerateUniqueSequentialSpaceName(conferenceName), new SequentialSpace()); string remoteName = NameHashingTool.GenerateUniqueRemoteSpaceUri(uri, conferenceName); ChatSpace = new RemoteSpace(remoteName); DataSource = dataSource; }
static void Main(string[] args) { if (args.Length > 1) { if (args[0] == "table") { // Instantiate a new space repository and add a gate to it. SpaceRepository repository = new SpaceRepository(); repository.AddGate("tcp://" + args[1] + ":31415?KEEP"); repository.AddGate("tcp://" + args[1] + ":31416?KEEP"); repository.AddGate("tcp://" + args[1] + ":31417?KEEP"); repository.AddGate("tcp://" + args[1] + ":31418?KEEP"); repository.AddGate("tcp://" + args[1] + ":31419?KEEP"); // Add a new Fifo based space to the repository. repository.AddSpace("DiningTable", new SequentialSpace()); // Insert the forks that the philosophers must share. repository.Put("DiningTable", "FORK", 1); repository.Put("DiningTable", "FORK", 2); repository.Put("DiningTable", "FORK", 3); repository.Put("DiningTable", "FORK", 4); repository.Put("DiningTable", "FORK", 5); return; } else if (args[0] == "philosopher") { Console.WriteLine("connecting " + args[1]); // Instantiate a new remote space, thereby allowing a persistant networked connection to the repository. ISpace remotespace1 = new RemoteSpace("tcp://" + args[1] + ":31415/DiningTable?KEEP"); ISpace remotespace2 = new RemoteSpace("tcp://" + args[1] + ":31416/DiningTable?KEEP"); ISpace remotespace3 = new RemoteSpace("tcp://" + args[1] + ":31417/DiningTable?KEEP"); ISpace remotespace4 = new RemoteSpace("tcp://" + args[1] + ":31418/DiningTable?KEEP"); ISpace remotespace5 = new RemoteSpace("tcp://" + args[1] + ":31419/DiningTable?KEEP"); // Instantiate the philosopher agents and let them use the same connection to access the repository. List <AgentBase> agents = new List <AgentBase>(); agents.Add(new Philosopher("Alice", 1, 5, remotespace1)); agents.Add(new Philosopher("Charlie", 2, 5, remotespace2)); agents.Add(new Philosopher("Bob", 3, 5, remotespace3)); agents.Add(new Philosopher("Dave", 4, 5, remotespace4)); agents.Add(new Philosopher("Homer", 5, 5, remotespace5)); // Let the philosophers eat. agents.ForEach(a => a.Start()); Console.Read(); return; } } Console.WriteLine("Please specify [table|philosopher] and IP address to use"); Console.Read(); }
public void UpgradePrivileges(string passwd) { var tuple = Space.QueryP("ConcealedIdentifier", typeof(string)); var token = tuple?.Get <string>(1); var hash = NameHashingTool.GetSHA256String(passwd); if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(passwd) && token == hash) { var id = NameHashingTool.GetSHA256String(passwd + token); ConcealedSpace = new RemoteSpace(string.Format(UriFormat, id)); _controlProducer = new ControlProducer(ConcealedSpace, SlideShower, Username); } }
public SlideClientFacade(ISlideShow slideShow, string conn, string username) { var regex = new Regex(@"\/(\?.*)?$"); UriFormat = regex.Replace(conn, "/{0}$1"); Username = username; SlideShower = slideShow; Space = new RemoteSpace(string.Format(UriFormat, "hub")); Session = new ClientSession(Space, Username); _frameConsumer = new FrameConsumer(Session); _controlConsumer = new ClientControlUnit(Session, SlideShower); }
public LogonWindow() { InitializeComponent(); DataContext = this; AccountCreation = new RemoteSpace("tcp://" + _Resources.Resources.InternetProtocolAddress + ":5001/accountCreation?CONN"); loginSpace = new RemoteSpace("tcp://" + _Resources.Resources.InternetProtocolAddress + ":5001/loginAttempts?CONN"); UsernameInput.KeyUp += PasswordInput_KeyUp; PasswordInput.KeyUp += PasswordInput_KeyUp; SignupButton.Click += SignupButton_Click; UsernameInput.GotFocus += FocusClearError; PasswordInput.GotFocus += FocusClearError; UsernameInput.Focus(); }
protected override void ProcessRecord() { var newSpace = new RemoteSpace { description = Description, key = SpaceKey, name = Name }; var space = WithDefaultPermissions ? Service.AddSpaceWithDefaultPermissions(newSpace) : Service.AddSpace(newSpace); WriteObject(new Space(space)); }
public static string RSAEncrypt(string Password) { var loginSpace = new RemoteSpace("tcp://" + _Resources.Resources.InternetProtocolAddress + ":5001/loginAttempts?CONN"); var PubKey = loginSpace.Query(typeof(string))[0] as string; byte[] BytePass = Encoding.UTF8.GetBytes(Password);// Convert.FromBase64String(Password); byte[] encryptedData; RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); RSA.FromXmlString(PubKey); encryptedData = RSA.Encrypt(BytePass, true); RSA.Dispose(); return(Convert.ToBase64String(encryptedData)); }
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); // //from https://stackoverflow.com/questions/743906/how-to-hide-close-button-in-wpf-window // //*****************************************************************************************// public ConferenceListWindow(string Username, string Password, string PubKey, RemoteSpace LoginSpace) { DataContext = this; Task.Factory.StartNew(Init); this.Username = Username; this.Password = Password; this.PubKey = PubKey; this.LoginSpace = LoginSpace; InitializeComponent(); RefreshButton.Click += RefreshButton_Click; //ConfList.MouseDoubleClick += ConfList_MouseDoubleClick; NewConferenceButton.Click += NewConferenceButton_Click; this.Loaded += Hack; CloseButton.Click += CloseButton_Click; }
public CreateConferenceWindow(RemoteSpace ConferenceRequests, string Username, ConferenceListWindow conferenceListWindow, string Password, RemoteSpace LoginSpace) { DataContext = this; this.conferenceListWindow = conferenceListWindow; this.ConferenceRequests = ConferenceRequests; this.LoginSpace = LoginSpace; this.Username = Username; this.Password = Password; InitializeComponent(); NewConferenceName.Focus(); NewConferenceName.KeyUp += EnterPressed; NewConferenceName.KeyDown += EnterPressed; CreateButton.Click += CreateButton_Click; cancelButton.Click += CancelClick; }
public SignupWindow(RemoteSpace AccountCreation, RemoteSpace loginSpace) { DataContext = this; this.AccountCreation = AccountCreation; this.loginSpace = loginSpace; InitializeComponent(); UsernameInput.KeyUp += PasswordInput_KeyUp; PasswordInput.KeyUp += PasswordInput_KeyUp; PasswordRepeat.KeyUp += PasswordInput_KeyUp; UsernameInput.GotFocus += FocusClearError; PasswordInput.GotFocus += FocusClearError; PasswordRepeat.GotFocus += FocusClearError; SignUpButton.Click += SignUpButton_Click; GoBackButton.Click += GoBackButton_Click; UsernameInput.Focus(); }
static void Main(string[] args) { RemoteSpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/lifeforms?KEEP", new EntityFactory()); TerminalInfo.Initialize(80, 24); Game lifeforms = new Game(remotespace); lifeforms.AddLifeform(3); lifeforms.AddLifeform(5); lifeforms.AddLifeform(7); lifeforms.AddLifeform(11); lifeforms.AddLifeform(13); lifeforms.Run(); Console.ReadKey(); lifeforms.Stop(); }
public static int GetNumberOfSubscribersInALobby(string lobbyUrl) { RemoteSpace lobbySpace = new RemoteSpace(lobbyUrl); IEnumerable <ITuple> subscriberTuple = lobbySpace.QueryAll("player", typeof(int), typeof(string)); int count = 0; foreach (ITuple subscriber in subscriberTuple) { if ((int)subscriber[1] > 0 && (string)subscriber[2] != "No user") { count++; } } return(count); }
public void CreateRemoteSpaceWithRemoteSpaceNameGeneratorTest() { using (var spaceRepo = new SpaceRepository()) { string uri = "tcp://127.0.0.1:5002"; string testRemoteName = "ThisNameDoesNotActuallyMatter"; string testSeqName = NameHashingTool.GenerateUniqueSequentialSpaceName(testRemoteName); Console.WriteLine(testSeqName); var testSeqSpace = new SequentialSpace(); spaceRepo.AddSpace(testSeqName, testSeqSpace); spaceRepo.AddGate(uri); var remoteHash = NameHashingTool.GenerateUniqueRemoteSpaceUri(uri, testRemoteName); Console.WriteLine(remoteHash); var testRemoteSpace = new RemoteSpace(remoteHash); } }
public Servidor(string ip, string port, SpaceRepository space) { this.ip = ip; this.port = port; this.repository = space; // instanciar space // var threaSpace = new Thread(() => this.StartSpace()); // threaSpace.Start(); // Thread.Sleep(100); this.remotespace = new RemoteSpace($"tcp://{this.ip}:{this.port}/chat?KEEP"); // apagador de mensagens var threaMensagens = new Thread(() => this.apagaMensagens()); threaMensagens.Start(); // apagador de salas var threaSalas = new Thread(() => this.apagaSalas()); threaSalas.Start(); }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Please specify player id [1|2]"); Console.Read(); return; } int playerId = int.Parse(args[0]); RemoteSpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/pong?KEEP", new EntityFactory()); TerminalInfo.Initialize(80, 24); Game pongGame = new Game(remotespace); pongGame.SetPlayer(playerId, "AI" + playerId); pongGame.Run(); Console.ReadKey(); pongGame.Stop(); }
public ConferenceWindow(string username, string conferenceName, string ip, string Password, RemoteSpace LoginSpace) //For client { DataContext = this; this.Password = Password; this.username = username; this.ConferenceName = conferenceName; this.LoginSpace = LoginSpace; InitializeComponent(); OpenPresentaion.Visibility = Visibility.Hidden; this.SizeChanged += Resize; SendButton.Click += SendButton_Click; this.TxtToSend = new TextRange(SendField.Document.ContentStart, SendField.Document.ContentEnd); SendField.KeyUp += SendField_KeyUp; this.MsgList = new ObservableCollection <string>(); this.Loaded += MainWindow_Loaded; this.conference = new ConferenceInitializer(username, conferenceName, ip, MsgList, this); MsgList.CollectionChanged += NewMessageReceived; Closed += OnClose_Client; }
public static void ConnectToServer() { string serverUrl = "tcp://" + ConnectionInfo.SERVER_ADDRESS + "/" + ConnectionInfo.SPACE_NAME + "?KEEP"; Console.WriteLine($"Connecting to server at '{serverUrl}'..."); ISpace space = new RemoteSpace(serverUrl); try { // Connection is made first time some request is being made space.QueryP("disregard this string content"); } catch (SocketException e) { Console.WriteLine("Connection to server failed\n"); throw e; } Connection.GlobalSpace = space; Console.WriteLine("Connection to server succeeded\n"); }
static void Main(string[] args) { // Instantiate a new Space repository. SpaceRepository repository = new SpaceRepository(); // Add a gate, such that we can connect to it. repository.AddGate("tcp://127.0.0.1:9876?KEEP"); // Add a new Fifo based space. repository.AddSpace("dtu", new SequentialSpace()); Console.WriteLine("Starting"); repository.Put("dtu", 0); // Instantiate a remotespace (a networked space) thereby connecting to the spacerepository. ISpace remotespace = new RemoteSpace("tcp://127.0.0.1:9876/dtu?KEEP"); // Instantiate a new agent, assign the tuple space and start it. AgentBase userA = new User("A", remotespace); AgentBase userB = new User("B", remotespace); userA.Start(); userB.Start(); }