public List <CommunicationNodeMessage> sendCommMessage(User user, string header, string body) { if (!this.commNodeUsers.ContainsKey(user.id)) { return(null); } /* * if (!user.commNodeRights.ContainsKey(this.id) || !user.commNodeRights[this.id].writeAccess) return null; */ CommunicationNodeMessage newMessage = new CommunicationNodeMessage(this.id, user.id, header, body); if (!this.commNodeMessages.TryAdd(newMessage.id, newMessage)) { return(null); } Core.Instance.dataConnection.saveCommNodeMessage(newMessage); if (Core.Instance.SendCommMessage != null) { var Serialized = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(newMessage); var otherUserIds = this.commNodeUsers.Where(e => e.Value.userId != user.id).Select(e => e.Value.userId).ToList(); object Ship = new { Message = Serialized }; Core.Instance.SendCommMessage(Ship, otherUserIds); } //fetch all messages since the users lastReadMessage value. This will include the actual message, and all from other users written in the meantime. List <CommunicationNodeMessage> result = getCommMessages(user, -1, -1); return(result); }
public void saveCommNodeMessage(SpacegameServer.Core.CommunicationNodeMessage message) { }