Inheritance: Object
 public Message CreateAckMessage(string MessageID, Node MessageTo)
 {
     Message p = new Message(network, MessageType.Ack);
     p.To = MessageTo.NodeID;
     p.Content = MessageID;
     return p;
 }
 internal void ProcessAckMessage(Node messageFrom, string hash)
 {
     if (network.AckMethods.ContainsKey(hash)) {
         AckMethod m = network.AckMethods[hash];
         m.CallMethod(DateTime.Now);
         network.AckMethods.Remove(hash);
     }
 }
Exemple #3
0
 public Memo(Network network, MemoInfo memoInfo)
 {
     this.network = network;
     this.id = memoInfo.ID;
     this.node = network.Nodes[memoInfo.FromNodeID];
     this.createdOn = memoInfo.CreatedOn;
     this.signature = memoInfo.Signature;
     this.subject = memoInfo.Subject;
     this.text = memoInfo.Text;
 }
        internal void ProcessAddMemoMessage(Node messageFrom, MemoInfo memoInfo)
        {
            Memo memo = new Memo (network, memoInfo);

            if (!Core.IsLocalNode(memo.Node)) {
                if (network.TrustedNodes.ContainsKey(memo.Node.NodeID) && memo.Verify() == false) {
                    LoggingService.LogWarning("Ignored a memo with an invalid signature!");
                    return;
                }
                network.AddOrUpdateMemo(memo);
            }
        }
 public Message CreateRequestInfoMessage(Node MessageTo)
 {
     Message m = new Message(network, MessageType.RequestInfo);
     m.To = MessageTo.NodeID;
     m.Content = "GIMME GIMME GIMME!";
     return m;
 }
 public Message CreateRequestFileMessage(Node node, IFileTransfer transfer)
 {
     var remoteFile = (RemoteFile)transfer.File;
      			Message p = new Message(network, MessageType.RequestFile);
      			p.To = node.NodeID;
     p.Content = new RequestFileInfo(remoteFile.RemoteFullPath, transfer.Id);
      			return p;
 }
Exemple #7
0
 public Memo(Network network)
 {
     this.network = network;
     this.node = network.Nodes[Core.MyNodeID];
     this.createdOn = DateTime.Now;
 }
 public Message CreateTransportDataMessage(Node to, string connectionId, byte[] data)
 {
     Message msg = new Message (network, MessageType.TransportConnect);
     msg.To = to.NodeID;
     msg.Content = new TransportDataInfo(connectionId, data);
     return msg;
 }
 public Message CreateSendFileMessage(Node SendTo, IFile theFile)
 {
     return CreateSendFileMessage(SendTo, theFile.FullPath, theFile.Size);
 }
Exemple #10
0
 public Message CreateSearchReplyMessage(Node To, SearchResultInfo result)
 {
     Message p = new Message(network, MessageType.SearchResult);
     p.To = To.NodeID;
     p.Content = result;
     return p;
 }
Exemple #11
0
 public Message CreateNewSessionKeyMessage(Node sessionWith, byte[] keyExchangeBytes)
 {
     Message p = new Message(network, MessageType.NewSessionKey);
     p.To = sessionWith.NodeID;
     p.Content = keyExchangeBytes;
     return p;
 }
Exemple #12
0
        public Message CreateMyKeyMessage(Node messageTo)
        {
            Message m = new Message(network, MessageType.MyKey);

            if (messageTo != null) {
                m.To = messageTo.NodeID;
            }

            KeyInfo info = new KeyInfo ();
            info.Key = Core.CryptoProvider.ToXmlString (false);
            info.Info = Core.Settings.NickName;

            m.Content = info;

            return m;
        }
Exemple #13
0
        public Message CreateMyInfoMessage(Node MessageTo)
        {
            Message p = new Message(network, MessageType.MyInfo);
            p.To = MessageTo.NodeID;
            TrustedNodeInfo t = network.TrustedNodes[MessageTo.NodeID];

            NodeInfo nodeInfo = new NodeInfo();

            nodeInfo.NodeID = network.LocalNode.NodeID;
            nodeInfo.NickName = network.LocalNode.NickName;

            nodeInfo.AvatarSize = network.LocalNode.AvatarSize;

            if (MessageTo.IsConnectedLocally == true || t.AllowNetworkInfo == true) {
                nodeInfo.DestinationInfos = Core.DestinationManager.DestinationInfos;
            }
            if (t.AllowProfile == true) {
                nodeInfo.RealName = network.LocalNode.RealName;
                nodeInfo.Email = network.LocalNode.Email;
            }
            nodeInfo.ClientName = network.LocalNode.ClientName;
            nodeInfo.ClientVersion = network.LocalNode.ClientVersion;
            if (t.AllowSharedFiles == true) {
                nodeInfo.Bytes = network.LocalNode.Bytes;
                nodeInfo.Files = network.LocalNode.Files;
            }

            List<ConnectionInfo> connections = new List<ConnectionInfo>();
            List<ChatRoomInfo> rooms = new List<ChatRoomInfo>();
            List<MemoInfo> memos = new List<MemoInfo>();

            foreach (INodeConnection con in network.Connections) {
                if (con.NodeLocal != MessageTo & con.NodeRemote != MessageTo) {
                    if (con.ConnectionState == ConnectionState.Ready | con.ConnectionState == ConnectionState.Remote) {
                        ConnectionInfo n = new ConnectionInfo();
                        Node ConnectionSourceNode = con.NodeLocal;
                        Node ConnectionDestNode = con.NodeRemote;
                        n.SourceNodeID = ConnectionSourceNode.NodeID;
                        n.SourceNodeNickname = ConnectionSourceNode.NickName;
                        n.DestNodeID = ConnectionDestNode.NodeID;
                        n.DestNodeNickname = ConnectionDestNode.NickName;
                        connections.Add (n);
                    }
                }
            }

            foreach (ChatRoom currentRoom in network.ChatRooms) {
                ChatRoomInfo roomInfo = new ChatRoomInfo();
                roomInfo.Id = currentRoom.Id;
                roomInfo.Name = currentRoom.Name;
                roomInfo.Users = new string[currentRoom.Users.Count];
                int x = 0;
                foreach (Node node in currentRoom.Users.Values) {
                    roomInfo.Users[x] = node.NodeID;
                    x ++;
                }
                rooms.Add(roomInfo);
            }

            foreach (Memo currentMemo in network.Memos) {
                if (Core.IsLocalNode(currentMemo.Node)) {
                    MemoInfo info = new MemoInfo(currentMemo);
                    memos.Add(info);
                }
            }

            nodeInfo.KnownConnections = connections.ToArray();
            nodeInfo.KnownChatRooms = rooms.ToArray();
            nodeInfo.KnownMemos = memos.ToArray();

            p.Content = nodeInfo;
            return p;
        }
Exemple #14
0
 public Message CreateMessageMessage(Node MessageTo, string MessageText)
 {
     Message p = new Message(network, MessageType.PrivateMessage);
     p.To = MessageTo.NodeID;
     p.Content = MessageText;
     return p;
 }
Exemple #15
0
 public Message CreateFileDetailsMessage(Node sendTo, LocalFile file)
 {
     Message message = new Message(network, MessageType.FileDetails);
     message.To = sendTo.NodeID;
     message.Content = new SharedFileListing(file, true);
     return message;
 }
Exemple #16
0
 public Message CreateCriticalErrorMessage(Node MessageTo, MeshworkError error)
 {
     Message m = new Message(network, MessageType.CriticalError);
     m.To = MessageTo.NodeID;
     m.Content = error;
     return m;
 }
Exemple #17
0
 public Message CreateConnectionDownMessage(Node ConnectionSourceNode, Node ConnectionDestNode)
 {
     return CreateConnectionDownMessage(ConnectionSourceNode.NodeID, ConnectionDestNode.NodeID);
 }
Exemple #18
0
 public Message CreateRequestKeyMessage(Node messageto)
 {
     Message m = new Message(network, MessageType.RequestKey);
     m.To = messageto.NodeID;
     m.Content = "MUST...GET...KEY!!!";
     return m;
 }
Exemple #19
0
        public Message CreateRespondDirListingMessage(Node messageTo, LocalDirectory directory)
        {
            SharedDirectoryInfo info = new SharedDirectoryInfo(directory);

            info.Files = directory.Files.Select(f => new SharedFileListing((LocalFile)f, false)).ToArray();
            info.Directories = directory.Directories.Select(d => d.Name).ToArray();

            Message message = new Message (network, MessageType.RespondDirListing);
            message.To = messageTo.NodeID;
            message.Content = info;
            return message;
        }
Exemple #20
0
 public Message CreateNonCriticalErrorMessage(Node To, MeshworkError error)
 {
     return CreateNonCriticalErrorMessage(To.NodeID, error);
 }
Exemple #21
0
 public Message CreateSendFileMessage(Node sendTo, string filePath, long fileSize)
 {
     throw new NotImplementedException();
     /*
     Message m = new Message(network, MessageType.SendFile);
     m.To = SendTo.NodeID;
     SharedFileInfo c = new SharedFileInfo();
     c.FileName = FilePath.Substring(FilePath.LastIndexOf("/") + 1);
     c.FileSize = FileSize;
     c.FileFullPath = FilePath;
     m.Content = c);
     return m;
     */
 }
Exemple #22
0
 public Message CreatePongMessage(Node messageTo, ulong timestamp)
 {
     Message p = new Message(network, MessageType.Pong);
     p.To = messageTo.NodeID;
     p.Content = timestamp;
     return p;
 }
Exemple #23
0
 public Message CreateTransportConnectMessage(Node to, string connectionId)
 {
     Message msg = new Message (network, MessageType.TransportConnect);
     msg.To = to.NodeID;
     msg.Content = connectionId;
     return msg;
 }
Exemple #24
0
 public Message CreateAvatarMessage(Node messageTo, byte[] avatarData)
 {
     Message message = new Message(network, MessageType.Avatar);
     message.To = messageTo.NodeID;
     message.Content = avatarData;
     return message;
 }
Exemple #25
0
        public Message CreateReadyMessage(Node MessageTo)
        {
            Message p = new Message(network, MessageType.Ready);
            p.To = MessageTo.NodeID;

            // TODO: Put anything here?
            p.Content = "READY!";
            return p;
        }
Exemple #26
0
 internal void AddUser(Node node)
 {
     users.Add(node.NodeID, node);
 }
Exemple #27
0
 public Message CreateChatInviteMessage(Node messageTo, ChatRoom room, string message, string password)
 {
     Message p = new Message(network, MessageType.ChatInvite);
     p.To = messageTo.NodeID;
     ChatInviteInfo c = new ChatInviteInfo();
     c.RoomId = room.Id;
     c.RoomName = room.Name;
     c.Message = message;
     c.Password = password;
     p.Content = c;
     return p;
 }
Exemple #28
0
 public Message CreateRequestAvatarMessage(Node messageTo)
 {
     Message message = new Message(network, MessageType.RequestAvatar);
     message.To = messageTo.NodeID;
     message.Content = "plzkthx";
     return message;
 }
Exemple #29
0
 internal void RemoveUser(Node node)
 {
     users.Remove(node.NodeID);
 }
Exemple #30
0
 public Message CreateRequestDirectoryMessage(Node messageTo, string requestedDirPath)
 {
     Message p = new Message(network, MessageType.RequestDirListing);
     p.To = messageTo.NodeID;
     p.Content = requestedDirPath;
     return p;
 }