Esempio n. 1
0
 private Dictionary<string, List<ThalamusClientProxy>> FilterActionPublicationMap(ThalamusClientProxy client, Dictionary<string, List<ThalamusClientProxy>> map)
 {
     throw new NotImplementedException();
 }
Esempio n. 2
0
 public bool IsClientAllowedToPublish(string characterName, string fullEventName, ThalamusClientProxy client)
 {
     if (!conflictRules.ContainsKey(characterName)) return true;
     if (!conflictRules[characterName].ContainsKey(fullEventName)) return true;
     if (conflictRules[characterName][fullEventName].ContainsKey(ConflictRule.ConflictTypes.ActionPublishing))
     {
         ConflictRule rule = conflictRules[characterName][fullEventName][ConflictRule.ConflictTypes.ActionPublishing];
         if (rule.UnsolvedClients.Contains(client.Name)) return true;
         else if (!rule.ClientsRules.ContainsKey(client.Name) || rule.ClientsRules[client.Name]) return true;
         return false;
     }
     else if (conflictRules[characterName][fullEventName].ContainsKey(ConflictRule.ConflictTypes.PerceptionPublishing))
     {
         ConflictRule rule = conflictRules[characterName][fullEventName][ConflictRule.ConflictTypes.PerceptionPublishing];
         if (rule.UnsolvedClients.Contains(client.Name)) return true;
         else if (!rule.ClientsRules.ContainsKey(client.Name) || rule.ClientsRules[client.Name]) return true;
         return false;
     }
     else return true;
 }
Esempio n. 3
0
 private Dictionary<string, List<ThalamusClientProxy>> FilterPerceptionSubscriptionMap(ThalamusClientProxy client, Dictionary<string, List<ThalamusClientProxy>> map)
 {
     if (!conflictRules.ContainsKey(client.Character.Name)) return map;
     Dictionary<string, List<ThalamusClientProxy>> result = new Dictionary<string, List<ThalamusClientProxy>>();
     Dictionary<string, Dictionary<ConflictRule.ConflictTypes, ConflictRule>> characterRules = conflictRules[client.Character.Name];
     foreach (KeyValuePair<string, List<ThalamusClientProxy>> ps in map)
     {
         if (!characterRules.ContainsKey(ps.Key) || !characterRules[ps.Key].ContainsKey(ConflictRule.ConflictTypes.PerceptionSubscription)) {
             result[ps.Key] = ps.Value;
         }
         else
         {
             ConflictRule rule = characterRules[ps.Key][ConflictRule.ConflictTypes.PerceptionSubscription];
             if (!rule.ClientsRules.ContainsKey(client.Name)) result[ps.Key] = ps.Value;
         }
     }
     return result;
 }
		public void PerformRegistration(ThalamusClientProxy client)
		{
            if (!client.SendMessage(() => client.SlowProxy.PerformRegistration(), "PerformRegistration"))
            {
				Environment.Instance.DebugIf("error", "Failed to request registration on client '{0}'!", client.Name);
			}
		}
		public string ConnectClient(string name, string clientId, string clientAddress, int clientFastPort, int clientSlowPort, int numSubscribedEvents)
        {
            string uid = Guid.NewGuid().ToString();
            if (clientId != "" && clientId!=null) uid = clientId;
            if (remoteClients.ContainsKey(uid)) return uid;

            Environment.Instance.Debug("Received new Client named: '{0}' from '{1}:{2}/{3}' with id {4}.", name, clientAddress, clientFastPort, clientSlowPort, uid);

            if (remoteClients.ContainsKey(uid)) return "";
            ThalamusClientProxy newClient = new ThalamusClientProxy(this, name, clientAddress, clientFastPort, clientSlowPort, uid, numSubscribedEvents);
			lock (remoteClients) {
				Dictionary<string, ThalamusClientProxy> newClients = new Dictionary<string, ThalamusClientProxy>(remoteClients);
				newClients.Add (uid, newClient);
				remoteClients = newClients;
			}
            lock (RegisteringClients)
            {
                RegisteringClients.Add(newClient);
            }
            return uid;
        }
 public void BroadcastEvent(string messageId, ThalamusClientProxy sourceClient, string eventName, string[] parameters, string[] types, string[] values, PML ev)
 {
     List<ThalamusClientProxy> clients;
     lock (remoteClients)
     {
         clients = new List<ThalamusClientProxy>(remoteClients.Values);
     }
     foreach (ThalamusClientProxy client in clients)
     {
         if (sourceClient != client && client.SubscribedEvents.Contains(eventName))
         {
             Environment.Instance.LogEvent(true, character, client, ev);
             client.QueueEvent(messageId, eventName, parameters, types, values, ev.DontLogDescription);
             outboundEventsCounter++;
         }
     }
     if (sourceClient != null) Environment.Instance.DebugIf("messages", "[T][" + sourceClient.Name + "]Published " + ev.ToString() + ".");
     else Environment.Instance.DebugIf("messages", "[T][Unknown]Published " + ev.ToString() + ".");
 }
		public void BroadcastEvent(ThalamusClientProxy sourceClient, PML p)
		{
			string[] parameters = new string[p.Parameters.Count];
			string[] values = new string[p.Parameters.Count];
			string[] types = new string[p.Parameters.Count];
			int i = 0;
			foreach (KeyValuePair<string, PMLParameter> param in p.Parameters)
			{
				parameters[i] = param.Key;
				values[i] = param.Value.ToString();
				types[i] = param.Value.Type.ToString();
				i++;
			}
            BroadcastEvent(Guid.NewGuid().ToString(), sourceClient, p.Name, parameters, types, values, p);
		}
Esempio n. 8
0
        public void LogEvent(bool outwards, Character character, ThalamusClientProxy client, PML ev)
        {
            LogEntry l = new LogEntry(outwards, CentralTimePassed().TotalSeconds, character.Name, client == null ? "GUI" : client.Name, ev);
			DebugLog(l.ToString());
            NotifyEventLogged(l);
            logs.Add(l);
            if (character.LogToCSV) lock (csvLogs) { csvLogs.Add(l); }
        }