Esempio n. 1
0
 public Message CreateAckMessage(string MessageID, Node MessageTo)
 {
     Message p = new Message(network, MessageType.Ack);
     p.To = MessageTo.NodeID;
     p.Content = MessageID;
     return p;
 }
Esempio n. 2
0
        public Message CreateAddMemoMessage(Memo memo)
        {
            MemoInfo memoInfo = new MemoInfo (memo);

            Message message = new Message (network, MessageType.AddMemo);
            message.Content = memoInfo;
            return message;
        }
Esempio n. 3
0
 public Message CreateAuthMessage(INodeConnection connection, TrustedNodeInfo messageTo)
 {
     Message p = new Message(network, MessageType.Auth);
     p.To = messageTo.NodeID;
     AuthInfo c = new AuthInfo();
     c.ProtocolVersion = Core.ProtocolVersion;
     c.NetworkName = network.NetworkName;
     c.NickName = network.LocalNode.NickName;
     p.Content = c;
     return p;
 }
Esempio n. 4
0
 public Message CreateRequestDirectoryMessage(Node messageTo, string requestedDirPath)
 {
     Message p = new Message(network, MessageType.RequestDirListing);
     p.To = messageTo.NodeID;
     p.Content = requestedDirPath;
     return p;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 public Message CreateDelMemoMessage(Memo theMemo)
 {
     Message theMessage = new Message(network, MessageType.DeleteMemo);
     theMessage.Content = theMemo.ID;
     return theMessage;
 }
Esempio n. 7
0
 public Message CreateChatMessageMessage(ChatRoom room, string messageText)
 {
     Message p = new Message(network, MessageType.ChatroomMessage);
     ChatMessage c = new ChatMessage();
     c.RoomId = room.Id;
     c.RoomName = room.Name;
     c.Message = messageText;
     //		p.To = "";
     p.Content = c;
     return p;
 }
Esempio n. 8
0
 public Message CreateSearchRequestMessage(int searchRequestId, string searchString, int page)
 {
     Message p = new Message(network, MessageType.SearchRequest);
     SearchRequestInfo c = new SearchRequestInfo(searchRequestId, searchString, page);
     p.Content = c;
     return p;
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
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;
        }
Esempio n. 11
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;
        }
Esempio n. 12
0
 public Message CreateMessageMessage(Node MessageTo, string MessageText)
 {
     Message p = new Message(network, MessageType.PrivateMessage);
     p.To = MessageTo.NodeID;
     p.Content = MessageText;
     return p;
 }
Esempio n. 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;
        }
Esempio n. 14
0
 public Message CreateLeaveChatMessage(ChatRoom room)
 {
     Message p = new Message(network, MessageType.LeaveChat);
     ChatAction c = new ChatAction();
     c.RoomId = room.Id;
     c.RoomName = room.Name;
     p.Content = c;
     return p;
 }
Esempio n. 15
0
        public Message CreateHelloMessage()
        {
            Message message = new Message (network, MessageType.Hello);
            HelloInfo hello = new HelloInfo ();

            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.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 tmpRoom = new ChatRoomInfo();
                tmpRoom.Id = currentRoom.Id;
                tmpRoom.Name = currentRoom.Name;
                tmpRoom.Users = new string[currentRoom.Users.Count];
                int x = 0;
                foreach (Node node in currentRoom.Users.Values) {
                    tmpRoom.Users[x] = node.NodeID;
                    x ++;
                }
                rooms.Add(tmpRoom);
            }

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

            hello.KnownConnections = connections.ToArray();
            hello.KnownChatRooms = rooms.ToArray();
            hello.KnownMemos = memos.ToArray();
            hello.MyNickName = network.LocalNode.NickName;

            message.Content = hello;
            return message;
        }
Esempio n. 16
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;
 }
Esempio n. 17
0
 public Message CreateRequestInfoMessage(Node MessageTo)
 {
     Message m = new Message(network, MessageType.RequestInfo);
     m.To = MessageTo.NodeID;
     m.Content = "GIMME GIMME GIMME!";
     return m;
 }
Esempio n. 18
0
 public Message CreateNewSessionKeyMessage(Node sessionWith, byte[] keyExchangeBytes)
 {
     Message p = new Message(network, MessageType.NewSessionKey);
     p.To = sessionWith.NodeID;
     p.Content = keyExchangeBytes;
     return p;
 }
Esempio n. 19
0
 public Message CreateRequestKeyMessage(Node messageto)
 {
     Message m = new Message(network, MessageType.RequestKey);
     m.To = messageto.NodeID;
     m.Content = "MUST...GET...KEY!!!";
     return m;
 }
Esempio n. 20
0
 public Message CreateNonCriticalErrorMessage(string To, MeshworkError error)
 {
     Message p = new Message(network, MessageType.NonCriticalError);
     p.To = To;
     p.Content = error;
     return p;
 }
Esempio n. 21
0
 public Message CreateSearchReplyMessage(Node To, SearchResultInfo result)
 {
     Message p = new Message(network, MessageType.SearchResult);
     p.To = To.NodeID;
     p.Content = result;
     return p;
 }
Esempio n. 22
0
 public Message CreateConnectionDownMessage(string ConnectionSourceNodeID, string ConnectionDestNodeID)
 {
     Message p = new Message(network, MessageType.ConnectionDown);
     ConnectionInfo c = new ConnectionInfo();
     c.SourceNodeID = ConnectionSourceNodeID;
     c.DestNodeID = ConnectionDestNodeID;
     p.Content = c;
     return p;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 25
0
 public Message CreatePongMessage(Node messageTo, ulong timestamp)
 {
     Message p = new Message(network, MessageType.Pong);
     p.To = messageTo.NodeID;
     p.Content = timestamp;
     return p;
 }
Esempio n. 26
0
 public Message CreateCriticalErrorMessage(Node MessageTo, MeshworkError error)
 {
     Message m = new Message(network, MessageType.CriticalError);
     m.To = MessageTo.NodeID;
     m.Content = error;
     return m;
 }
Esempio n. 27
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;
        }
Esempio n. 28
0
 public Message CreateRequestAvatarMessage(Node messageTo)
 {
     Message message = new Message(network, MessageType.RequestAvatar);
     message.To = messageTo.NodeID;
     message.Content = "plzkthx";
     return message;
 }
Esempio n. 29
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;
 }
Esempio n. 30
0
        private void messageSenderSendButton_Clicked(object sender, EventArgs args)
        {
            TreeIter iter;
            if (messageSenderToComboBox.GetActiveIter(out iter)) {

                Network network = (Network)messageSenderToComboBox.Model.GetValue(iter, 1);
                Node node = (Node)messageSenderToComboBox.Model.GetValue(iter, 2);

                for (int x = 0; x < 10; x++) {
                    Thread thread = new Thread(delegate () {
                        try {
                            for (int y = 0; y < 10; y++) {
                                double kilobytes = messageSenderSizeSpinButton.Value;
                                string data = new String('X', (int)kilobytes * 1024);

                                Message message = new Message(network, MessageType.Test);
                                message.To = node.NodeID;
                                message.Content = data;

                                AckMethod m = new AckMethod();
                                m.Method += MessageSent;
                                network.AckMethods.Add(message.MessageID, m);

                                network.SendRoutedMessage(message);

                                Gtk.Application.Invoke(delegate {
                                    messageSenderLogTextView.Buffer.Text += "\nSending...";
                                });
                            }
                        } catch (Exception ex) {
                            Gtk.Application.Invoke(delegate {
                                messageSenderLogTextView.Buffer.Text += "\n" + ex;
                            });
                        }
                    });
                    thread.Start();
                }
            }
        }