Inheritance diagram for DCPlusPlus.Hub:


Public Types | |
| enum | ConnectionMode { Active, Passive } |
| Enumeration of all possible connection modes for a hub. More... | |
| enum | ConnectionSpeed { kbps_28_8, kbps_33_6, kbps_56, satellite, isdn, dsl, cable, lan_t1, lan_t3, modem } |
| Enumeration of Old ConnectionSpeeds. More... | |
| enum | SearchFileType { any = 1, audio = 2, compressed = 3, documents = 4, executables = 5, pictures = 6, video = 7, folders = 8, tth = 9 } |
| Enumeration of File Types used in a search request. More... | |
Public Member Functions | |
| void | Connect () |
| Connect to the hub. | |
| delegate void | ConnectedEventHandler (Hub hub) |
| Prototype for the Connected Event Handler. | |
| delegate void | ConnectToMeEventHandler (Hub hub, Peer connection) |
| Prototype for the Connect To Me Event Handler. | |
| Hub | Copy () |
| Copy the hub's values into a new hub instance and return it this will not duplicate a connection / socket - only values. | |
| override void | Disconnect () |
| Disconnect the hub. | |
| delegate void | DisconnectedEventHandler (Hub hub) |
| Prototype for the Disconnected Event Handler. | |
| void | GetUserInfo (string username) |
| Get the info for a specific user this will send GetInfo to the hub (TODO no event for this kind of received data implemented). | |
| Hub () | |
| Hub Constructor this will initialize some values to default. | |
| delegate void | LoggedInEventHandler (Hub hub) |
| Prototype for the Logged In Event Handler. | |
| delegate void | MainChatLineReceivedEventHandler (Hub hub, ChatLine line) |
| Prototype for the Main Chat Line Received Event Handler. | |
| delegate void | MoveForcedEventHandler (Hub src_hub, Hub dst_hub) |
| Prototype for the Move Forced Event Handler. | |
| delegate string | PasswordRequestedEventHandler (Hub hub) |
| Prototype for the Password Requested Event Handler. | |
| delegate void | PrivateChatLineReceivedEventHandler (Hub hub, ChatLine line) |
| Prototype for the Private Chat Line Received Event Handler. | |
| void | Reconnect () |
| Reconnect the hub. | |
| void | Search (string search_tth, bool is_tth) |
| Search for a tth on this hub. | |
| void | Search (SearchParameters sp) |
| Search for something on this hub. | |
| void | Search (string search_string, bool size_restricted, bool is_max_size, long size, SearchFileType file_type) |
| Search for something on this hub. | |
| void | Search (string search_string) |
| Search for something on this hub. | |
| delegate void | SearchReceivedEventHandler (Hub hub, SearchParameters search) |
| Prototype for the Search Received Event Handler. | |
| void | SearchReply (string result_name, long filesize, SearchParameters search) |
| Reply to a search from a user (only used if the connection is passive). | |
| delegate void | SearchResultReceivedEventHandler (Hub hub, SearchResults.SearchResult result) |
| Prototype for the Search Result Received Event Handler. | |
| void | SendChatMessage (string message, string username, bool show_in_main_chat) |
| Send a private message to a hub user that will be shown in his hub main chat window. | |
| void | SendChatMessage (string message, string username) |
| Send a private message to a hub user. | |
| void | SendChatMessage (string message) |
| Send a chat message to the hub. | |
| void | SendConnectToMe (string username) |
| Send a connection request to a specific user this will automatically select the correct command according to the hubs connection mode. | |
| void | SendConnectToMeV2 (string username) |
| Send a connection request to a specific user Version 2 (actually use this for something or at least investigate what this was meant for). | |
| void | SendMyInfo () |
| Send the client information but only if an update is needed. | |
| void | SendPassword (string password) |
| Send a password to the hub. | |
| [Test] void | TestLocalHubConnect () |
| Test to connect to a local hub. | |
| delegate void | UnableToConnectEventHandler (Hub hub) |
| Prototype for the Unable To Connect Event Handler. | |
| void | Ungrab () |
| Remove the event handlers from the hub. | |
| delegate void | UserJoinedEventHandler (Hub hub, string username) |
| Prototype for the User Joined Event Handler. | |
| delegate void | UserQuitEventHandler (Hub hub, string username) |
| Prototype for the User Quit Event Handler. | |
Public Attributes | |
| event ConnectedEventHandler | Connected |
| Event handler that gets called when a hub connection was established. | |
| event ConnectToMeEventHandler | ConnectToMeReceived |
| Event handler that gets called when connection request was received. | |
| event DisconnectedEventHandler | Disconnected |
| Event handler that gets called when a hub was disconnected. | |
| event LoggedInEventHandler | LoggedIn |
| Event handler that gets called when the client logged in a hub. | |
| event MainChatLineReceivedEventHandler | MainChatLineReceived |
| Event handler that gets called when a chat message was received from a hub. | |
| event MoveForcedEventHandler | MoveForced |
| Event handler that gets called when a hub wants us to connect to another hub. | |
| event PasswordRequestedEventHandler | PasswordRequested |
| Event handler that gets called when a hub requested a password to use the specified username should return the password if it is known. | |
| event PrivateChatLineReceivedEventHandler | PrivateChatLineReceived |
| Event handler that gets called when a private message was received from a hub. | |
| event SearchReceivedEventHandler | SearchReceived |
| Event handler that gets called when a search was received (another user wants to find something). | |
| event SearchResultReceivedEventHandler | SearchResultReceived |
| Event handler that gets called when a search result was received via the hub connection (passive result). | |
| event UnableToConnectEventHandler | UnableToConnect |
| Event handler that gets called when a connection to a hub was unable to be established. | |
| event UserJoinedEventHandler | UserJoined |
| Event handler that gets called when a user joined a hub. | |
| event UserQuitEventHandler | UserQuit |
| Event handler that gets called when a user was disconnected from a hub. | |
Protected Attributes | |
| string | address = "" |
| bool | auto_reconnect = false |
| List< ChatLine > | chat_history = new List<ChatLine>() |
| int | chat_history_max_length = 0 |
| string | country = "" |
| string | description = "" |
| bool | is_grabbed = false |
| bool | is_logged_in = false |
| int | max_hubs = 0 |
| long | max_users = 0 |
| long | min_share = 0 |
| int | min_slots = 0 |
| ConnectionMode | my_connection_mode = ConnectionMode.Passive |
| string | my_connection_speed = "0.02" |
| string | my_description = "" |
| string | my_email = "unknown@unknown.net" |
| string | my_ip = "" |
| string | my_name = "c#++" |
| long | my_share_size = 0 |
| string | my_tag_version = "0.698" |
| int | my_tcp_port = 0 |
| int | my_udp_port = 0 |
| string | my_version = "1,0091" |
| string | name = "" |
| List< string > | op_list = new List<string>() |
| long | shared = 0 |
| string | topic = "" |
| List< string > | user_list = new List<string>() |
| long | users = 0 |
Properties | |
| string | Address [get, set] |
| the hub address | |
| bool | AutoReconnect [get, set] |
| TODO add auto reconnect feature [not implemented]. | |
| List< ChatLine > | ChatHistory [get, set] |
| the chat history of the hub (Todo change this to a enumeration at the moment it can throw list modified exceptions) | |
| int | ChatHistoryMaxLength [get, set] |
| the maximum chat history length if reached chat lines will be discarded | |
| string | Country [get, set] |
| the country in which the hubs resides in | |
| string | Description [get, set] |
| the hub description | |
| bool | IsGrabbedByClient [get, set] |
| TRUE if a client has added some event handlers to this hub. | |
| bool | IsLoggedIn [get] |
| TRUE if we are logged into this hub. | |
| int | MaxHubs [get, set] |
| the maximum number of hubs a client can be connected to to connect to this hub | |
| long | MaxUsers [get, set] |
| the maximum number of users this hub supports | |
| long | MinShare [get, set] |
| the minimum amount of shared bytes a client needs to connect to this hub | |
| int | MinSlots [get, set] |
| the minimum amount of open slots a client needs to connect to this hub | |
| ConnectionMode | MyConnectionMode [get, set] |
| the connection mode to use on this hub this will decide how to connect to peers active or passive | |
| string | MyConnectionSpeed [get, set] |
| the connection speed of the client pc to the internet | |
| string | MyDescription [get, set] |
| the user description | |
| string | MyEmail [get, set] |
| the email address of the user | |
| string | MyIP [get, set] |
| set it to the external ip of the client pc it will we used for active connection requests | |
| string | MyName [get, set] |
| the name of the client | |
| long | MyShareSize [get, set] |
| the total number of shared bytes by the client | |
| string | MyTagVersion [get, set] |
| the version of the client that is used in the myinfo tag | |
| int | MyTcpPort [get, set] |
| the local tcp port used by the client to accept remote connections | |
| int | MyUdpPort [get, set] |
| the local udp port used by the client to receive udp search results | |
| string | MyVersion [get, set] |
| the version of the client | |
| string | Name [get, set] |
| the hub name | |
| List< string > | OperatorList [get, set] |
| the operators connected to this hub (Todo change this to a enumeration at the moment it can throw list modified exceptions) TODO add operator events and make them more usable as sources | |
| long | Shared [get, set] |
| the number of shared bytes on the hub | |
| string | Topic [get] |
| the topic of the hub | |
| List< string > | UserList [get, set] |
| the users connected to this hub (Todo change this to a enumeration at the moment it can throw list modified exceptions) | |
| long | Users [get, set] |
| the number of users connected to the hub (as replied from a hublist) TODO support returning of UserList.Count | |
Private Member Functions | |
| void | AddChatToHistory (string username, string message) |
| Add a chat line to the chat history of a hub if the chat history max length is != 0 it will automatically remove the first lines added if needed (FIFO buffer). | |
| void | InterpretCommand (string received_command) |
| Interpret a single command. | |
| void | InterpretReceivedString (string received_string) |
| Interpret a received string. this will split the string into single commands and call InterpretCommand() with them. | |
| void | OnConnect (IAsyncResult result) |
| Callback for hub connecting. | |
| void | OnHostResolve (IAsyncResult result) |
| Callback for hostname resolving. | |
| void | OnReceive (IAsyncResult result) |
| Callback to receive data from the hub. | |
| void | SendChatMessageCallback (IAsyncResult ar) |
| Callback for the send chat command. | |
| void | UserListAdd (string username) |
| Add a user to the userlist and fires an user joined event. | |
| void | UserListClear () |
| Clear the userlist this will UserListRemove() them first so a lot of events maybe triggered by this. | |
| void | UserListRemove (string username) |
| Remove a user from the userlist and fires an user quit event. | |
Private Attributes | |
| string | received_string_buffer = "" |
| a temporary fifo buffer to fight packet fragmentation and incomplete commands that packet fragmentation introduces | |
Classes | |
| class | ChatLine |
| a single line of chat More... | |
| class | FileParameters |
| a filename filesize pair More... | |
| class | SearchParameters |
| the parameters needed for a search More... | |
Definition at line 25 of file Hub.cs.
Enumeration of Old ConnectionSpeeds.
Definition at line 757 of file Hub.cs.
00758 { 00763 kbps_28_8,// = "28.8Kbps", 00768 kbps_33_6,// = "33.6Kbps", 00773 kbps_56,// = "56Kbps", 00778 satellite,// = "Satellite", 00783 isdn,// = "ISDN", 00788 dsl,// = "DSL", 00793 cable,// = "Cable", 00798 lan_t1,// = "LAN(T1)", 00803 lan_t3,// = "LAN(T3)", 00808 modem,// = "Modem" 00809 }
Enumeration of File Types used in a search request.
Definition at line 1143 of file Hub.cs.
01144 { 01148 any = 1, 01152 audio = 2, 01156 compressed = 3, 01160 documents = 4, 01164 executables = 5, 01168 pictures = 6, 01172 video = 7, 01176 folders = 8, 01180 tth = 9 01181 }
| DCPlusPlus.Hub.Hub | ( | ) |
Hub Constructor this will initialize some values to default.
Definition at line 864 of file Hub.cs.
References DCPlusPlus.Connection.is_connected, DCPlusPlus.Connection.is_connecting, DCPlusPlus.Connection.is_extended_protocol, DCPlusPlus.Hub.is_logged_in, DCPlusPlus.Connection.port, and DCPlusPlus.Connection.socket.
00865 { 00866 is_connecting = false; 00867 is_connected = false; 00868 is_extended_protocol = false; 00869 is_logged_in = false; 00870 socket = null; 00871 port = 411; 00872 //Disconnect(); 00873 }
| void DCPlusPlus.Hub.AddChatToHistory | ( | string | username, | |
| string | message | |||
| ) | [private] |
Add a chat line to the chat history of a hub if the chat history max length is != 0 it will automatically remove the first lines added if needed (FIFO buffer).
| username | the user who wrote the chat message | |
| message | the message contents |
Definition at line 1327 of file Hub.cs.
01328 { 01329 if (chat_history_max_length != 0) 01330 {//using max history -> delete first line added to list 01331 if (chat_history.Count > chat_history_max_length) 01332 chat_history.RemoveAt(0); 01333 } 01334 ChatLine cline = new ChatLine(username, message); 01335 chat_history.Add(cline); 01336 if (MainChatLineReceived != null) 01337 MainChatLineReceived(this,cline); 01338 01339 }
| void DCPlusPlus.Hub.Connect | ( | ) |
Connect to the hub.
Definition at line 924 of file Hub.cs.
References DCPlusPlus.Hub.address, DCPlusPlus.Hub.Disconnect(), DCPlusPlus.Connection.error_code, DCPlusPlus.Connection.Exception, DCPlusPlus.Connection.is_connected, DCPlusPlus.Connection.is_connecting, DCPlusPlus.Hub.name, DCPlusPlus.Hub.OnHostResolve(), DCPlusPlus.Connection.socket, and DCPlusPlus.Connection.UserDisconnect.
Referenced by DCPlusPlus.Client.ConnectHub(), DCPlusPlus.Hub.Reconnect(), and DCPlusPlus.Hub.TestLocalHubConnect().
00925 { 00926 if (is_connecting) 00927 {//better handling of fast user retries 00928 error_code = ErrorCodes.UserDisconnect; 00929 Disconnect(); 00930 } 00931 if (!is_connected) 00932 { 00933 //Console.WriteLine("Connecting to Hub: "+name); 00934 try 00935 { 00936 is_connecting = true; 00937 socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 00938 socket.Blocking = false; 00939 AsyncCallback event_host_resolved = new AsyncCallback(OnHostResolve); 00940 Dns.BeginGetHostEntry(address, event_host_resolved, socket); 00941 //IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(address),port); 00942 //IPHostEntry ip = Dns.GetHostEntry(address); 00943 } 00944 catch (Exception ex) 00945 { 00946 error_code = ErrorCodes.Exception; 00947 Console.WriteLine("Error connecting to Hub: " + name + "(exception:" + ex.Message + ")"); 00948 Disconnect(); 00949 } 00950 } 00951 }
Here is the call graph for this function:

Here is the caller graph for this function:

| delegate void DCPlusPlus.Hub.ConnectedEventHandler | ( | Hub | hub | ) |
Prototype for the Connected Event Handler.
| hub | the hub we connected to |
Prototype for the Connect To Me Event Handler.
| hub | the hub on which the request was issued on | |
| connection | the connection endpoint information |
| Hub DCPlusPlus.Hub.Copy | ( | ) |
Copy the hub's values into a new hub instance and return it this will not duplicate a connection / socket - only values.
Definition at line 1733 of file Hub.cs.
References DCPlusPlus.Hub.address, DCPlusPlus.Hub.auto_reconnect, DCPlusPlus.Hub.Connected, DCPlusPlus.Hub.country, DCPlusPlus.Hub.description, DCPlusPlus.Hub.Disconnected, DCPlusPlus.Connection.ip, DCPlusPlus.Connection.is_connected, DCPlusPlus.Connection.is_connecting, DCPlusPlus.Connection.is_extended_protocol, DCPlusPlus.Hub.is_grabbed, DCPlusPlus.Hub.is_logged_in, DCPlusPlus.Hub.LoggedIn, DCPlusPlus.Hub.max_hubs, DCPlusPlus.Hub.max_users, DCPlusPlus.Hub.min_share, DCPlusPlus.Hub.min_slots, DCPlusPlus.Hub.MoveForced, DCPlusPlus.Hub.my_connection_mode, DCPlusPlus.Hub.my_connection_speed, DCPlusPlus.Hub.my_email, DCPlusPlus.Hub.my_ip, DCPlusPlus.Hub.my_name, DCPlusPlus.Hub.my_share_size, DCPlusPlus.Hub.my_tag_version, DCPlusPlus.Hub.my_tcp_port, DCPlusPlus.Hub.my_udp_port, DCPlusPlus.Hub.my_version, DCPlusPlus.Hub.name, DCPlusPlus.Connection.nick, DCPlusPlus.Hub.op_list, DCPlusPlus.Connection.port, DCPlusPlus.Hub.SearchResultReceived, DCPlusPlus.Hub.shared, DCPlusPlus.Hub.topic, DCPlusPlus.Hub.UnableToConnect, DCPlusPlus.Hub.user_list, DCPlusPlus.Hub.UserJoined, DCPlusPlus.Hub.UserList, DCPlusPlus.Hub.UserQuit, and DCPlusPlus.Hub.users.
01734 { 01735 Hub ret = new Hub(); 01736 ret.address = this.address; 01737 ret.auto_reconnect = this.auto_reconnect; 01738 ret.country = this.country; 01739 ret.description = this.description; 01740 ret.ip = this.ip; 01741 ret.is_connecting = false; 01742 ret.is_connected = false; 01743 ret.is_extended_protocol = false; 01744 ret.is_grabbed = this.is_grabbed; 01745 ret.is_logged_in = false; 01746 ret.Connected = this.Connected; 01747 ret.Disconnected = this.Disconnected; 01748 ret.UnableToConnect = this.UnableToConnect; 01749 ret.LoggedIn = this.LoggedIn; 01750 ret.SearchResultReceived = this.SearchResultReceived; 01751 ret.UserJoined = this.UserJoined; 01752 ret.UserQuit = this.UserQuit; 01753 ret.MoveForced = this.MoveForced; 01754 ret.max_hubs = 0; 01755 ret.max_users = 0; 01756 ret.min_share = 0; 01757 ret.min_slots = 0; 01758 ret.my_connection_mode = this.my_connection_mode; 01759 ret.my_connection_speed = this.my_connection_speed; 01760 ret.my_email = this.my_email; 01761 ret.my_ip = this.my_ip; 01762 ret.my_name = this.my_name; 01763 ret.my_share_size = this.my_share_size; 01764 ret.my_tag_version = this.my_tag_version; 01765 ret.my_tcp_port = this.my_tcp_port; 01766 ret.my_udp_port = this.my_udp_port; 01767 ret.my_version = this.my_version; 01768 ret.name = this.name; 01769 ret.nick = this.nick; 01770 ret.op_list = new List<string>(); 01771 ret.port = this.port; 01772 ret.shared = 0; 01773 ret.topic = this.topic; 01774 ret.user_list = new List<string>(); 01775 ret.UserList = new List<string>(); 01776 ret.users = 0; 01777 return (ret); 01778 }
| override void DCPlusPlus.Hub.Disconnect | ( | ) | [virtual] |
Disconnect the hub.
Implements DCPlusPlus.Connection.
Definition at line 885 of file Hub.cs.
References DCPlusPlus.Hub.Disconnected, DCPlusPlus.Connection.error_code, DCPlusPlus.Connection.Exception, DCPlusPlus.Connection.is_connected, DCPlusPlus.Connection.is_connecting, DCPlusPlus.Connection.is_extended_protocol, DCPlusPlus.Hub.is_logged_in, DCPlusPlus.Hub.name, DCPlusPlus.Connection.socket, and DCPlusPlus.Hub.UnableToConnect.
Referenced by DCPlusPlus.Hub.Connect(), DCPlusPlus.Client.DisconnectHub(), DCPlusPlus.Hub.OnHostResolve(), DCPlusPlus.Hub.Reconnect(), and DCPlusPlus.Hub.TestLocalHubConnect().
00886 { 00887 if (is_connected || is_connecting) 00888 { 00889 try 00890 { 00891 if (socket != null && socket.Connected) 00892 { 00893 //if(receive_operation!=null) socket //socket.EndReceive(receive_operation); 00894 socket.Shutdown(SocketShutdown.Both); 00895 //Thread.Sleep(10); 00896 socket.Close(); 00897 socket = null; 00898 //receive_operation = null; 00899 } 00900 if (is_connected) 00901 { 00902 if (Disconnected != null) 00903 Disconnected(this); 00904 }else if (is_connecting) 00905 { 00906 if (UnableToConnect != null) 00907 UnableToConnect(this); 00908 } 00909 is_connecting = false; 00910 is_connected = false; 00911 is_extended_protocol = false; 00912 is_logged_in = false; 00913 } 00914 catch (Exception ex) 00915 { 00916 Console.WriteLine("Error disconnecting Hub: " + name + "(exception:" + ex.Message + ")"); 00917 error_code = ErrorCodes.Exception; 00918 } 00919 } 00920 }
Here is the caller graph for this function:

| delegate void DCPlusPlus.Hub.DisconnectedEventHandler | ( | Hub | hub | ) |
Prototype for the Disconnected Event Handler.
| hub | the hub that was disconnected |
| void DCPlusPlus.Hub.GetUserInfo | ( | string | username | ) |
Get the info for a specific user this will send GetInfo to the hub (TODO no event for this kind of received data implemented).
| username | the user from which to get info from |
Definition at line 1278 of file Hub.cs.
01279 {//TODO finish this 01280 01281 SendCommand("GetInfo",username+" "+nick); 01282 }
| void DCPlusPlus.Hub.InterpretCommand | ( | string | received_command | ) | [private] |
Interpret a single command.
| received_command | the command to interpret |
Definition at line 1446 of file Hub.cs.
References DCPlusPlus.Hub.SearchParameters.file_type, DCPlusPlus.Hub.SearchParameters.ip, DCPlusPlus.Hub.SearchParameters.is_max_size, DCPlusPlus.Hub.SearchParameters.mode, DCPlusPlus.Hub.SearchParameters.port, DCPlusPlus.Hub.SearchParameters.search_string, DCPlusPlus.Hub.SearchParameters.size, DCPlusPlus.Hub.SearchParameters.size_restricted, DCPlusPlus.Hub.SearchParameters.tth, and DCPlusPlus.Hub.SearchParameters.username.
01447 { 01448 int command_end = received_command.IndexOf(" "); 01449 if (command_end == -1) command_end = received_command.Length; 01450 01451 if (command_end != -1) 01452 { 01453 string parameter = ""; 01454 string[] parameters ={ }; 01455 string command = received_command.Substring(1); 01456 if (command_end != received_command.Length) 01457 { 01458 command = received_command.Substring(1, command_end - 1); 01459 parameter = received_command.Substring(command_end + 1); 01460 parameters = parameter.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 01461 //Console.WriteLine("Command: '" + command + "' ,Parameter(" + parameters.Length + "): '" + parameter + "'"); 01462 } 01463 switch (command) 01464 { 01465 case "HubName" : 01466 //Console.WriteLine("Hubname Command received: " + parameter); 01467 name = parameter; 01468 //fire nameChange event 01469 break; 01470 01471 case "Hello" : 01472 //Console.WriteLine("Hello Command received: " + parameters[0]); 01473 if (!is_logged_in) 01474 { 01475 is_logged_in = true; 01476 SendCommand("Version", my_version); 01477 SendCommand("GetNickList"); 01478 SendMyInfo(); 01479 //Console.WriteLine("Logged in Hub: "+name); 01480 try 01481 { 01482 if (LoggedIn != null) 01483 LoggedIn(this); 01484 } 01485 catch (Exception ex) 01486 { 01487 Console.WriteLine("Exception in LoggedIn: " + ex.Message); 01488 } 01489 } 01490 else 01491 {//new user announced by server 01492 //Console.WriteLine("User "+parameters[0]+" has joined Hub: "+name); 01493 UserListAdd(parameters[0]); 01494 } 01495 break; 01496 01497 case "Quit": 01498 //Console.WriteLine("User "+parameters[0]+" has left Hub: "+name); 01499 UserListRemove(parameters[0]); 01500 break; 01501 01502 case "NickList": 01503 Console.WriteLine("NickList Message received."); 01504 UserListClear(); 01505 string[] temp_users = parameters[0].Split("$$".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 01506 foreach (string temp_user in temp_users) 01507 { 01508 UserListAdd(temp_user); 01509 } 01510 break; 01511 01512 case "OpList": 01513 op_list.Clear(); 01514 string[] temp_ops = parameters[0].Split("$$".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 01515 foreach (string temp_op in temp_ops) 01516 { 01517 op_list.Add(temp_op); 01518 } 01519 break; 01520 01521 case "ConnectToMe": 01522 try 01523 { 01524 string peer_address = ""; 01525 if (parameters.Length == 2) 01526 { 01527 peer_address = parameters[1]; 01528 } 01529 else if (parameters.Length == 3) 01530 { 01531 peer_address = parameters[2]; 01532 } 01533 else break; 01534 Peer peer = new Peer(peer_address); //add username also, to counter possible network attacks 01535 if (ConnectToMeReceived != null) 01536 ConnectToMeReceived(this, peer); 01537 } 01538 catch (Exception ex) 01539 { 01540 Console.WriteLine("Exception in ConnectToMe EventHandler: " + ex.Message); 01541 } 01542 break; 01543 01544 case "RevConnectToMe": 01545 SendConnectToMe(parameters[0]); 01546 break; 01547 01548 case "HubTopic": 01549 //topic = parameters[0]; 01550 topic = parameter; 01551 break; 01552 01553 case "UserCommand": 01554 //Console.WriteLine("User Command received: "+parameter); 01555 //TODO support user context menu entries 01556 break; 01557 01558 case "Search": 01559 //Console.WriteLine("Search Command received: "+parameter); 01560 SearchParameters search = new SearchParameters(); 01561 if(parameters[0].StartsWith("Hub:")) 01562 { 01563 search.mode = ConnectionMode.Passive; 01564 int username_start = parameters[0].IndexOf(":"); 01565 if (username_start == -1 || username_start + 1 > parameters[0].Length) break; 01566 search.username = parameters[0].Substring(username_start + 1); 01567 } 01568 else 01569 { 01570 search.mode = ConnectionMode.Active; 01571 int port_start = parameters[0].IndexOf(":"); 01572 if (port_start == -1 || port_start + 1 > parameters[0].Length) break; 01573 search.ip = parameters[0].Substring(0,port_start); 01574 try 01575 { 01576 search.port = int.Parse(parameters[0].Substring(port_start + 1)); 01577 } 01578 catch (Exception ex) 01579 { 01580 Console.WriteLine("error parsing port in search: " + ex.Message); 01581 break; 01582 } 01583 } 01584 01585 char[] seps ={ '?' }; 01586 string[] search_parameters = parameters[1].Split(seps,StringSplitOptions.RemoveEmptyEntries); 01587 if (search_parameters.Length < 4) break; 01588 if (search_parameters[0] == "F") 01589 search.size_restricted = false; 01590 else search.size_restricted = true; 01591 if (search_parameters[1] == "F") 01592 search.is_max_size = false; 01593 else search.is_max_size = true; 01594 try 01595 { 01596 search.size = long.Parse(search_parameters[2]); 01597 search.file_type = (SearchFileType)int.Parse(search_parameters[3]); 01598 } 01599 catch (Exception ex) 01600 { 01601 Console.WriteLine("error parsing ints in search: " + ex.Message); 01602 break; 01603 } 01604 if (search_parameters[4].StartsWith("TTH:") && search.file_type == SearchFileType.tth) 01605 search.tth = search_parameters[4].Substring(4); 01606 else search.search_string = search_parameters[4]; 01607 01608 if (SearchReceived != null) 01609 SearchReceived(this,search); 01610 break; 01611 01612 case "Supports": 01613 supports = (string[])parameters.Clone(); 01614 break; 01615 01616 case "UserIP": 01617 Console.WriteLine("UserIP Message received: " + parameter); 01618 break; 01619 01620 case "MCTo:": 01621 string mcto_username = parameters[1].Substring(1); //to skip the leading $ 01622 int mcto_message_start = parameters[0].Length + parameters[1].Length + 2; 01623 if (mcto_message_start < parameter.Length) 01624 { 01625 string mcto_message = parameter.Substring(mcto_message_start); 01626 AddChatToHistory(mcto_username, mcto_message); 01627 } 01628 break; 01629 01630 case "To:": 01631 //Console.WriteLine("Private Message received: " + parameter); 01632 string to_username = parameters[2]; 01633 int to_message_start = parameters[0].Length + parameters[1].Length + parameters[2].Length + parameters[3].Length + 4; 01634 if (to_message_start < parameter.Length ) 01635 { 01636 string to_message = parameter.Substring(to_message_start); 01637 ChatLine to_message_line = new ChatLine(to_username, to_message); 01638 if (PrivateChatLineReceived != null) 01639 PrivateChatLineReceived(this, to_message_line); 01640 } 01641 break; 01642 01643 case "SR": 01644 //Console.WriteLine("Search result received: " + parameter); 01645 SearchResults.SearchResult result = new SearchResults.SearchResult(); 01646 result.ResultLine = parameter; 01647 try 01648 { 01649 if (SearchResultReceived != null) 01650 SearchResultReceived(this, result); 01651 } 01652 catch (Exception ex) 01653 { 01654 Console.WriteLine("Exception in event handler: " + ex.Message); 01655 } 01656 01657 break; 01658 01659 case "LogedIn": 01660 Console.WriteLine("LogedIn Message received: " + parameter); 01661 //what the hell is this and who forgot to take some english lessons ? 01662 break; 01663 case "MyINFO": 01664 //Console.WriteLine("MyINFO Message received: " + parameter); 01665 UserListAdd(parameters[1]); 01666 break; 01667 case "GetPass": 01668 Console.WriteLine("GetPass Message received: " + parameter); 01669 if (PasswordRequested != null) 01670 { 01671 string password = PasswordRequested(this); 01672 SendPassword(password); 01673 } 01674 break; 01675 01676 case "ForceMove": 01677 //Console.WriteLine("FORCE MOVE NOT IMPLEMENTED"); 01678 if (MoveForced != null) 01679 { 01680 Hub dst_hub = this.Copy(); 01681 MoveForced(this, dst_hub); 01682 } 01683 break; 01684 01685 case "ValidateDenide": 01686 Console.WriteLine("Nick: "+parameters[0]+" on Hub: " + name + " is already in use."); 01687 break; 01688 01689 case "HubIsFull": 01690 Console.WriteLine("Hub: " + name + " is full."); 01691 Disconnect(); 01692 break; 01693 01694 case "Lock" : 01695 //Console.WriteLine("Lock Command received: "+parameter); 01696 //int key_end = parameter.IndexOf(" "); 01697 //if (key_end != -1) 01698 //{ 01699 //string key = parameter.Substring(0, key_end); 01700 if (parameters.Length > 1) 01701 { 01702 string key = parameters[0]; 01703 //Console.WriteLine("Key: " + key); 01704 if (key.StartsWith("EXTENDEDPROTOCOL")) 01705 { 01706 is_extended_protocol = true; 01707 //Console.WriteLine("Hub is using the dc++ protocol enhancements."); 01708 //SendCommand("Supports", "UserCommand NoGetINFO NoHello UserIP2 TTHSearch ZPipe0 GetZBlock "); 01709 SendCommand("Supports", "UserCommand TTHSearch NoGetINFO NoHello "); 01710 } 01711 01712 //string decoded_key = MyLockToKey(key); 01713 string decoded_key = L2K(key); 01714 //Console.WriteLine("Decoded key: " + decoded_key); 01715 SendCommand("Key" , decoded_key); 01716 SendCommand("ValidateNick", nick); 01717 01718 01719 } 01720 break; 01721 default: 01722 Console.WriteLine("Unknown Command received: " + command + ", Parameter: " + parameter); 01723 break; 01724 } 01725 } 01726 else Console.WriteLine("Error interpreting command: " + received_command); 01727 }
| void DCPlusPlus.Hub.InterpretReceivedString | ( | string | received_string | ) | [private] |
Interpret a received string. this will split the string into single commands and call InterpretCommand() with them.
| received_string | the data received from the hub |
Definition at line 1401 of file Hub.cs.
01402 { 01403 // possible strings 01404 //$command| 01405 //<chat> 01406 //| 01407 received_string_buffer += received_string; 01408 //if (received_string_buffer.IndexOf("|") == -1) return;//incomplete command 01409 int last_command_marker = received_string_buffer.LastIndexOf("|"); 01410 if (last_command_marker != -1) 01411 { 01412 string command_strings = received_string_buffer.Substring(0, last_command_marker); 01413 01414 //received_string_buffer = received_string_buffer.Substring(last_command_marker); 01415 received_string_buffer = received_string_buffer.Remove(0, last_command_marker); 01416 string[] received_strings = command_strings.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 01417 for (int i = 0; i < received_strings.Length; i++) 01418 { 01419 if (received_strings[i].StartsWith("<")) 01420 { 01421 int user_end_marker = received_strings[i].IndexOf(">"); 01422 if (user_end_marker != -1) 01423 { 01424 string user = received_strings[i].Substring(1, user_end_marker - 1); 01425 string message = ""; 01426 if ((user_end_marker + 1) < received_strings[i].Length) 01427 message = received_strings[i].Substring(user_end_marker+1); 01428 AddChatToHistory(user, message); 01429 } 01430 else Console.WriteLine("Received a wrong chat line: " + received_strings[i]); 01431 //Console.WriteLine("chat message on hub: " + name + " - " + received_strings[i]); 01432 } 01433 else 01434 { 01435 if (received_strings[i].StartsWith("$")) InterpretCommand(received_strings[i]); 01436 //else Console.WriteLine("Received a non command line: " + received_strings[i]); 01437 } 01438 } 01439 } 01440 01441 }
| delegate void DCPlusPlus.Hub.LoggedInEventHandler | ( | Hub | hub | ) |
Prototype for the Logged In Event Handler.
| hub | the hub that you successfully logged in |
Prototype for the Main Chat Line Received Event Handler.
| hub | the hub on which the chat was send | |
| line | the chat line received |
Prototype for the Move Forced Event Handler.
| src_hub | the hub that wants us to move | |
| dst_hub | the destination the source hub has suggested |
| void DCPlusPlus.Hub.OnConnect | ( | IAsyncResult | result | ) | [private] |
Callback for hub connecting.
| result | Async Result/State |
Definition at line 1005 of file Hub.cs.
Referenced by DCPlusPlus.Hub.OnHostResolve().
01006 { 01007 Socket connect_socket = (Socket)result.AsyncState; 01008 try 01009 { 01010 if (connect_socket.Connected) 01011 { 01012 AsyncCallback event_receive = new AsyncCallback(OnReceive); 01013 receive_buffer = new byte[32768]; 01014 connect_socket.BeginReceive(receive_buffer, 0, receive_buffer.Length, SocketFlags.None, event_receive, connect_socket); 01015 //Console.WriteLine("Successfully connected to Hub: " + name); 01016 try 01017 { 01018 if (Connected != null) 01019 Connected(this); 01020 } 01021 catch (Exception ex) 01022 { 01023 error_code = ErrorCodes.Exception; 01024 Console.WriteLine("Exception in Connected event: " + ex.Message); 01025 Disconnect(); 01026 } 01027 is_connecting = false; 01028 is_connected = true; 01029 } 01030 else 01031 { 01032 error_code = ErrorCodes.UnableToConnect; 01033 Console.WriteLine("Unable to connect to server: " + name); 01034 Disconnect(); 01035 } 01036 01037 } 01038 catch (Exception ex) 01039 { 01040 error_code = ErrorCodes.Exception; 01041 Console.WriteLine("Error during connect to Hub: " + name + "(exception:" + ex.Message + ")"); 01042 Disconnect(); 01043 } 01044 }
Here is the caller graph for this function:

| void DCPlusPlus.Hub.OnHostResolve | ( | IAsyncResult | result | ) | [private] |
Callback for hostname resolving.
| result | Async Result/State |
Definition at line 956 of file Hub.cs.
References DCPlusPlus.Hub.address, DCPlusPlus.Hub.Disconnect(), DCPlusPlus.Connection.error_code, DCPlusPlus.Connection.ip, DCPlusPlus.Hub.name, DCPlusPlus.Hub.OnConnect(), DCPlusPlus.Connection.port, DCPlusPlus.Connection.socket, and DCPlusPlus.Connection.UnableToConnect.
Referenced by DCPlusPlus.Hub.Connect().
00957 { 00958 Socket resolve_socket = (Socket)result.AsyncState; 00959 try 00960 { 00961 IPHostEntry ip_entry = Dns.EndGetHostEntry(result); 00962 if (ip_entry != null && ip_entry.AddressList.Length > 0) 00963 { 00964 ip = ip_entry.AddressList[0].ToString(); // correct the ip string 00965 IPEndPoint endpoint = new IPEndPoint(ip_entry.AddressList[0], port); 00966 AsyncCallback event_connect = new AsyncCallback(OnConnect); 00967 socket.BeginConnect(endpoint, event_connect, socket); 00968 } 00969 else 00970 { 00971 Console.WriteLine("Unable to connect to server: " + name + "(address:" + address + ")"); 00972 error_code = ErrorCodes.UnableToConnect; 00973 Disconnect(); 00974 } 00975 00976 } 00977 00978 catch (SocketException sex) 00979 { 00980 if (sex.ErrorCode == 11001) //TODO i know , or correctly i dont know ... 00981 { 00982 error_code = ErrorCodes.UnableToConnect; 00983 Console.WriteLine("Error during Address resolve of Hub: " + name + "(address:" + address + ")"); 00984 Disconnect(); 00985 } 00986 else 00987 { 00988 error_code = ErrorCodes.UnableToConnect; 00989 Console.WriteLine("Error during Address resolve of Hub: " + name + "(address:" + address + ")"); 00990 Disconnect(); 00991 } 00992 00993 } 00994 catch (Exception ex) 00995 { 00996 error_code = ErrorCodes.Exception; 00997 Console.WriteLine("Error during Address resolve of Hub: " + name + "(address:" + address +",exception:"+ex.Message+")"); 00998 Disconnect(); 00999 } 01000 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void DCPlusPlus.Hub.OnReceive | ( | IAsyncResult | result | ) | [private] |
Callback to receive data from the hub.
| result | Async Result/State |
Definition at line 1049 of file Hub.cs.
01050 { 01051 Socket receive_socket = (Socket)result.AsyncState; 01052 if (!receive_socket.Connected) return;//TODO change to disconnect(); 01053 try 01054 { 01055 int received_bytes = receive_socket.EndReceive(result); 01056 if (received_bytes > 0) 01057 { 01058 //string received_string = Encoding.ASCII.GetString(receive_buffer, 0, received_bytes); 01059 string received_string = System.Text.Encoding.Default.GetString(receive_buffer, 0, received_bytes); 01060 //Console.WriteLine("Received a string: "+received_string); 01061 //interpret string and act accordingly 01062 InterpretReceivedString(received_string); 01063 AsyncCallback event_receive = new AsyncCallback(OnReceive); 01064 receive_socket.BeginReceive(receive_buffer, 0, receive_buffer.Length, SocketFlags.None, event_receive, receive_socket); 01065 } 01066 else 01067 { 01068 Disconnect(); 01069 } 01070 01071 } 01072 catch (Exception ex) 01073 { 01074 error_code = ErrorCodes.Exception; 01075 Console.WriteLine("Error receiving data from Hub: " + name + "(exception:" + ex.Message + ")"); 01076 Disconnect(); 01077 } 01078 01079 }
| delegate string DCPlusPlus.Hub.PasswordRequestedEventHandler | ( | Hub | hub | ) |
Prototype for the Password Requested Event Handler.
| hub | the hub which asks for a password |
Prototype for the Private Chat Line Received Event Handler.
| hub | the hub on which the private message was send | |
| line | the private message |
| void DCPlusPlus.Hub.Reconnect | ( | ) |
Reconnect the hub.
Definition at line 877 of file Hub.cs.
References DCPlusPlus.Hub.Connect(), and DCPlusPlus.Hub.Disconnect().
00878 { 00879 Disconnect(); 00880 Connect(); 00881 }
Here is the call graph for this function:

| void DCPlusPlus.Hub.Search | ( | string | search_tth, | |
| bool | is_tth | |||
| ) |
Search for a tth on this hub.
| search_tth | the tth to search for | |
| is_tth | Must be TRUE,or else a normal search would be started |
Definition at line 1236 of file Hub.cs.
01237 { 01238 if (!is_tth) 01239 Search(search_tth); 01240 else 01241 { 01242 Search("TTH:" + search_tth,false,false,0,SearchFileType.tth); 01243 } 01244 }
| void DCPlusPlus.Hub.Search | ( | SearchParameters | sp | ) |
Search for something on this hub.
| sp | all search parameters in one single parameter |
Definition at line 1227 of file Hub.cs.
References DCPlusPlus.Hub.SearchParameters.file_type, DCPlusPlus.Hub.SearchParameters.is_max_size, DCPlusPlus.Hub.SearchParameters.search_string, DCPlusPlus.Hub.SearchParameters.size, and DCPlusPlus.Hub.SearchParameters.size_restricted.
01228 { 01229 Search(sp.search_string, sp.size_restricted, sp.is_max_size, sp.size, sp.file_type); 01230 }
| void DCPlusPlus.Hub.Search | ( | string | search_string, | |
| bool | size_restricted, | |||
| bool | is_max_size, | |||
| long | size, | |||
| SearchFileType | file_type | |||
| ) |
Search for something on this hub.
| search_string | the term you want to search for | |
| size_restricted | TRUE if you want to restrict your search to a specific size range | |
| is_max_size | TRUE if you want to size restrict your search to a max size | |
| size | the size you want to use in your size resstriction,only used if size_restricted is set to TRUE | |
| file_type | the specific filetype to search for ,default will be ANY |
Definition at line 1198 of file Hub.cs.
01199 { 01200 //"Search Hub:[DE]Test F?F?0?1?extras" 01201 //string send_string = "<" + nick + "> " + message + "|"; 01202 string parameter = ""; 01203 if (my_connection_mode == ConnectionMode.Active) 01204 { 01205 parameter = my_ip + ":" + my_udp_port.ToString() + " "; 01206 } 01207 else if (my_connection_mode == ConnectionMode.Passive) 01208 { 01209 parameter = "Hub:" + nick + " "; 01210 } 01211 if (size_restricted) 01212 parameter += "T?"; 01213 else parameter += "F?"; 01214 if (is_max_size) 01215 parameter += "T?"; 01216 else parameter += "F?"; 01217 01218 parameter += size.ToString()+"?"; 01219 parameter += ((int)file_type).ToString()+"?"; 01220 parameter += search_string.Replace(' ','$'); 01221 SendCommand("Search",parameter); 01222 }
| void DCPlusPlus.Hub.Search | ( | string | search_string | ) |
Search for something on this hub.
| search_string | the term you want to search for |
Definition at line 1186 of file Hub.cs.
01187 { 01188 Search(search_string,false,false,0,SearchFileType.any); 01189 }
| delegate void DCPlusPlus.Hub.SearchReceivedEventHandler | ( | Hub | hub, | |
| SearchParameters | search | |||
| ) |
Prototype for the Search Received Event Handler.
| hub | the hub on which the search was issued | |
| search | the search parameters received |
| void DCPlusPlus.Hub.SearchReply | ( | string | result_name, | |
| long | filesize, | |||
| SearchParameters | search | |||
| ) |
Reply to a search from a user (only used if the connection is passive).
| result_name | the filename of the share found | |
| filesize | the filesize of the share | |
| search | a whole lot of parameters of the search initiated by a remote user (including ip and port,which we will need here) |
Definition at line 1252 of file Hub.cs.
References DCPlusPlus.Hub.SearchParameters.HasTTH, DCPlusPlus.Hub.SearchParameters.mode, DCPlusPlus.Hub.SearchParameters.tth, and DCPlusPlus.Hub.SearchParameters.username.
Referenced by DCPlusPlus.Client.ConnectHub().
01253 { 01254 if (search.mode == ConnectionMode.Passive) 01255 { 01256 string temp_hub = name; 01257 if (search.HasTTH) temp_hub = "TTH:" + search.tth; 01258 string reply_parameter = nick + " " + result_name + (char)0x05 + filesize + " 1/1" + (char)0x05 + temp_hub + " (" + ip + ":" + port + ")" + (char)0x05 + search.username; 01259 Console.WriteLine("Replying to passive search: " + reply_parameter); 01260 SendCommand("SR", reply_parameter); 01261 } 01262 }
Here is the caller graph for this function:

| delegate void DCPlusPlus.Hub.SearchResultReceivedEventHandler | ( | Hub | hub, | |
| SearchResults.SearchResult | result | |||
| ) |
Prototype for the Search Result Received Event Handler.
| hub | the hub on which the search result was found | |
| result | the search result received |
| void DCPlusPlus.Hub.SendChatMessage | ( | string | message, | |
| string | username, | |||
| bool | show_in_main_chat | |||
| ) |
Send a private message to a hub user that will be shown in his hub main chat window.
| message | the message to send | |
| username | to which user you want to send it | |
| show_in_main_chat | must be set to TRUE |
Definition at line 1134 of file Hub.cs.
01135 { 01136 if (show_in_main_chat) 01137 SendCommand("MCTo: " + username + " $" + nick + " " + message); 01138 else SendChatMessage(message, username); 01139 }
| void DCPlusPlus.Hub.SendChatMessage | ( | string | message, | |
| string | username | |||
| ) |
Send a private message to a hub user.
| message | the message to send | |
| username | to which user you want to send it |
Definition at line 1123 of file Hub.cs.
01124 { 01125 SendCommand("To: " + username + " From: " + nick + " $<" + nick + "> " + message); 01126 }
| void DCPlusPlus.Hub.SendChatMessage | ( | string | message | ) |
Send a chat message to the hub.
| message | the message you want to tell the other hub users |
Definition at line 1084 of file Hub.cs.
01085 { 01086 string send_string = "<" + nick + "> " + message + "|"; 01087 try 01088 { 01089 //socket.Send(Encoding.UTF8.GetBytes(send_string), SocketFlags.None); 01090 byte[] send_bytes = System.Text.Encoding.Default.GetBytes(send_string); 01091 socket.BeginSend(send_bytes, 0, send_bytes.Length, SocketFlags.None, new AsyncCallback(SendChatMessageCallback), socket); 01092 } 01093 catch (Exception e) 01094 { 01095 error_code = ErrorCodes.Exception; 01096 Console.WriteLine("Error sending chat message to Hub: " + name + "(exception:" + e.Message + ")"); 01097 Disconnect(); 01098 } 01099 }
| void DCPlusPlus.Hub.SendChatMessageCallback | ( | IAsyncResult | ar | ) | [private] |
Callback for the send chat command.
| ar | Async Result/State |
Definition at line 1104 of file Hub.cs.
01105 { 01106 Socket send_chat_message_socket = (Socket)ar.AsyncState; 01107 try 01108 { 01109 int bytes = send_chat_message_socket.EndSend(ar); 01110 } 01111 catch (Exception ex) 01112 { 01113 error_code = ErrorCodes.Exception; 01114 Console.WriteLine("Error during sending chat message to Hub: " + name + "(exception:" + ex.Message + ")"); 01115 Disconnect(); 01116 } 01117 }
| void DCPlusPlus.Hub.SendConnectToMe | ( | string | username | ) |
Send a connection request to a specific user this will automatically select the correct command according to the hubs connection mode.
| username | the user to connect to |
Definition at line 1289 of file Hub.cs.
Referenced by DCPlusPlus.Client.GetFileList().
01290 { 01291 if (my_connection_mode == ConnectionMode.Active) 01292 SendCommand("ConnectToMe", username + " " + my_ip + ":" + my_tcp_port); 01293 else SendCommand("RevConnectToMe",nick + " " + username); 01294 }
Here is the caller graph for this function:

| void DCPlusPlus.Hub.SendConnectToMeV2 | ( | string | username | ) |
Send a connection request to a specific user Version 2 (actually use this for something or at least investigate what this was meant for).
| username | the user to connect to |
Definition at line 1300 of file Hub.cs.
01301 { 01302 SendCommand("ConnectToMe", nick + " " + username + " " + my_ip + ":" + my_tcp_port); 01303 }
| void DCPlusPlus.Hub.SendMyInfo | ( | ) |
Send the client information but only if an update is needed.
Definition at line 1307 of file Hub.cs.
01308 { 01309 string temp_connection_mode = ""; 01310 //check if info changed and a myinfo command is actually needed 01311 if (my_connection_mode == Hub.ConnectionMode.Active) temp_connection_mode = "A"; 01312 else if (my_connection_mode == Hub.ConnectionMode.Passive) temp_connection_mode = "P"; 01313 //else if (my_connection_mode == Hub.ConnectionMode.Socks5) temp_connection_mode = "5"; 01314 //SendCommand("MyINFO", "$ALL " + parameters[0] + " <" + my_name + " V:" + my_tag_version + ",M:" + temp_connection_mode + ",H:0/0/0,S:2>$ $Cable1$" + my_email + "$" + my_share_size.ToString() + "$"); 01315 //TODO add user flag support and hubs accounting 01316 SendCommand("MyINFO", "$ALL " + nick + " "+my_description+"<" + my_name + " V:" + my_tag_version + ",M:" + temp_connection_mode + ",H:1/2/2,S:2>$ $"+my_connection_speed+(char)0x01+"$" + my_email + "$" + my_share_size.ToString() + "$"); 01317 // ,O:0 01318 }
| void DCPlusPlus.Hub.SendPassword | ( | string | password | ) |
Send a password to the hub.
| password | the correct password |
Definition at line 1267 of file Hub.cs.
01268 { 01269 if (string.IsNullOrEmpty(password)) return; 01270 SendCommand("MyPass", password); 01271 }
| [Test] void DCPlusPlus.Hub.TestLocalHubConnect | ( | ) |
Test to connect to a local hub.
Definition at line 1799 of file Hub.cs.
References DCPlusPlus.Hub.Address, DCPlusPlus.Hub.Connect(), DCPlusPlus.Hub.Connected, DCPlusPlus.Hub.Disconnect(), DCPlusPlus.Hub.Disconnected, DCPlusPlus.Hub.IsGrabbedByClient, DCPlusPlus.Hub.LoggedIn, and DCPlusPlus.Hub.UnableToConnect.
01800 { 01801 Console.WriteLine("Test to connect to a local hub (remember to start some hub before)."); 01802 bool wait = true; 01803 Hub hub = new Hub(); 01804 hub.Address = "localhost"; 01805 hub.Connected += delegate(Hub connected) 01806 { 01807 Console.WriteLine("Hub Connected"); 01808 //Assert.IsTrue(!string.IsNullOrEmpty(external_ip), "no ip address fetched"); 01809 //wait = false; 01810 }; 01811 hub.LoggedIn += delegate(Hub logged_in) 01812 { 01813 Console.WriteLine("Hub Logged in"); 01814 wait = false; 01815 }; 01816 hub.Disconnected += delegate(Hub disconnected) 01817 { 01818 if (wait) 01819 { 01820 Console.WriteLine("Test failed : Hub disconnected."); 01821 Assert.Fail("Test failed : Hub disconnected."); 01822 } 01823 }; 01824 hub.UnableToConnect += delegate(Hub error) 01825 { 01826 Console.WriteLine("Test failed : Unable to connect to"); 01827 }; 01828 hub.IsGrabbedByClient = true; 01829 hub.Connect(); 01830 Console.WriteLine("Waiting for hub events."); 01831 DateTime start = DateTime.Now; 01832 while (wait) 01833 { 01834 if (DateTime.Now - start > new TimeSpan(0, 0, 10)) 01835 { 01836 Console.WriteLine(""); 01837 Console.WriteLine("Operation took too long"); 01838 wait = false; 01839 Assert.Fail("Operation took too long"); 01840 } 01841 Console.Write("."); 01842 Thread.Sleep(250); 01843 } 01844 hub.Disconnect(); 01845 Console.WriteLine("Local Hub Connect Test successful."); 01846 }
Here is the call graph for this function:

| delegate void DCPlusPlus.Hub.UnableToConnectEventHandler | ( | Hub | hub | ) |
Prototype for the Unable To Connect Event Handler.
| hub | the hub we failed to connect to |
| void DCPlusPlus.Hub.Ungrab | ( | ) |
Remove the event handlers from the hub.
Definition at line 1782 of file Hub.cs.
Referenced by DCPlusPlus.Client.DisconnectHub().
01783 { 01784 Connected = null; 01785 Disconnected = null; 01786 UnableToConnect = null; 01787 LoggedIn = null; 01788 SearchResultReceived = null; 01789 UserJoined = null; 01790 UserQuit = null; 01791 MoveForced = null; 01792 is_grabbed = false; 01793 }
Here is the caller graph for this function:

| delegate void DCPlusPlus.Hub.UserJoinedEventHandler | ( | Hub | hub, | |
| string | username | |||
| ) |
Prototype for the User Joined Event Handler.
| hub | the hub to which the user connected to | |
| username | the user that went online |
| void DCPlusPlus.Hub.UserListAdd | ( | string | username | ) | [private] |
Add a user to the userlist and fires an user joined event.
| username | the user connected to the hub |
Definition at line 1345 of file Hub.cs.
01346 { 01347 user_list.Add(username); 01348 try 01349 { 01350 if (UserJoined != null) 01351 UserJoined(this, username); 01352 } 01353 catch (Exception ex) 01354 { 01355 Console.WriteLine("Exception in UserJoined: " + ex.Message); 01356 } 01357 }
| void DCPlusPlus.Hub.UserListClear | ( | ) | [private] |
Clear the userlist this will UserListRemove() them first so a lot of events maybe triggered by this.
Definition at line 1381 of file Hub.cs.
01382 { 01383 if(user_list.Count>0) 01384 foreach (string temp_user in user_list) 01385 { 01386 UserListRemove(temp_user); 01387 } 01388 user_list.Clear(); 01389 }
| void DCPlusPlus.Hub.UserListRemove | ( | string | username | ) | [private] |
Remove a user from the userlist and fires an user quit event.
| username | the user that disconnected from the hub |
Definition at line 1363 of file Hub.cs.
01364 { 01365 user_list.Remove(username); 01366 try 01367 { 01368 if (UserQuit != null) 01369 UserQuit(this, username); 01370 } 01371 catch (Exception ex) 01372 { 01373 Console.WriteLine("Exception in UserJoined: " + ex.Message); 01374 } 01375 }
| delegate void DCPlusPlus.Hub.UserQuitEventHandler | ( | Hub | hub, | |
| string | username | |||
| ) |
Prototype for the User Quit Event Handler.
| hub | the hub from which the user disconnected | |
| username | the user that went offline |
string DCPlusPlus.Hub.address = "" [protected] |
Definition at line 307 of file Hub.cs.
Referenced by DCPlusPlus.Hub.Connect(), DCPlusPlus.Hub.Copy(), and DCPlusPlus.Hub.OnHostResolve().
bool DCPlusPlus.Hub.auto_reconnect = false [protected] |
List<ChatLine> DCPlusPlus.Hub.chat_history = new List<ChatLine>() [protected] |
int DCPlusPlus.Hub.chat_history_max_length = 0 [protected] |
| event ConnectedEventHandler DCPlusPlus.Hub.Connected |
Event handler that gets called when a hub connection was established.
Definition at line 157 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), DCPlusPlus.Hub.Copy(), and DCPlusPlus.Hub.TestLocalHubConnect().
| event ConnectToMeEventHandler DCPlusPlus.Hub.ConnectToMeReceived |
Event handler that gets called when connection request was received.
Definition at line 137 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.country = "" [protected] |
string DCPlusPlus.Hub.description = "" [protected] |
| event DisconnectedEventHandler DCPlusPlus.Hub.Disconnected |
Event handler that gets called when a hub was disconnected.
Reimplemented from DCPlusPlus.Connection.
Definition at line 147 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), DCPlusPlus.Hub.Copy(), DCPlusPlus.Hub.Disconnect(), and DCPlusPlus.Hub.TestLocalHubConnect().
bool DCPlusPlus.Hub.is_grabbed = false [protected] |
bool DCPlusPlus.Hub.is_logged_in = false [protected] |
Definition at line 493 of file Hub.cs.
Referenced by DCPlusPlus.Hub.Copy(), DCPlusPlus.Hub.Disconnect(), and DCPlusPlus.Hub.Hub().
| event LoggedInEventHandler DCPlusPlus.Hub.LoggedIn |
Event handler that gets called when the client logged in a hub.
Definition at line 103 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), DCPlusPlus.Hub.Copy(), and DCPlusPlus.Hub.TestLocalHubConnect().
| event MainChatLineReceivedEventHandler DCPlusPlus.Hub.MainChatLineReceived |
Event handler that gets called when a chat message was received from a hub.
Definition at line 60 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
int DCPlusPlus.Hub.max_hubs = 0 [protected] |
long DCPlusPlus.Hub.max_users = 0 [protected] |
long DCPlusPlus.Hub.min_share = 0 [protected] |
int DCPlusPlus.Hub.min_slots = 0 [protected] |
| event MoveForcedEventHandler DCPlusPlus.Hub.MoveForced |
Event handler that gets called when a hub wants us to connect to another hub.
Definition at line 126 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), and DCPlusPlus.Hub.Copy().
ConnectionMode DCPlusPlus.Hub.my_connection_mode = ConnectionMode.Passive [protected] |
string DCPlusPlus.Hub.my_connection_speed = "0.02" [protected] |
string DCPlusPlus.Hub.my_description = "" [protected] |
string DCPlusPlus.Hub.my_email = "unknown@unknown.net" [protected] |
string DCPlusPlus.Hub.my_ip = "" [protected] |
string DCPlusPlus.Hub.my_name = "c#++" [protected] |
long DCPlusPlus.Hub.my_share_size = 0 [protected] |
string DCPlusPlus.Hub.my_tag_version = "0.698" [protected] |
int DCPlusPlus.Hub.my_tcp_port = 0 [protected] |
int DCPlusPlus.Hub.my_udp_port = 0 [protected] |
string DCPlusPlus.Hub.my_version = "1,0091" [protected] |
string DCPlusPlus.Hub.name = "" [protected] |
Definition at line 292 of file Hub.cs.
Referenced by DCPlusPlus.Hub.Connect(), DCPlusPlus.Hub.Copy(), DCPlusPlus.Hub.Disconnect(), and DCPlusPlus.Hub.OnHostResolve().
List<string> DCPlusPlus.Hub.op_list = new List<string>() [protected] |
| event PasswordRequestedEventHandler DCPlusPlus.Hub.PasswordRequested |
Event handler that gets called when a hub requested a password to use the specified username should return the password if it is known.
Definition at line 115 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
| event PrivateChatLineReceivedEventHandler DCPlusPlus.Hub.PrivateChatLineReceived |
Event handler that gets called when a private message was received from a hub.
Definition at line 71 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.received_string_buffer = "" [private] |
| event SearchReceivedEventHandler DCPlusPlus.Hub.SearchReceived |
Event handler that gets called when a search was received (another user wants to find something).
Definition at line 49 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
| event SearchResultReceivedEventHandler DCPlusPlus.Hub.SearchResultReceived |
Event handler that gets called when a search result was received via the hub connection (passive result).
Definition at line 37 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), and DCPlusPlus.Hub.Copy().
long DCPlusPlus.Hub.shared = 0 [protected] |
string DCPlusPlus.Hub.topic = "" [protected] |
| event UnableToConnectEventHandler DCPlusPlus.Hub.UnableToConnect |
Event handler that gets called when a connection to a hub was unable to be established.
Reimplemented from DCPlusPlus.Connection.
Definition at line 167 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), DCPlusPlus.Hub.Copy(), DCPlusPlus.Hub.Disconnect(), and DCPlusPlus.Hub.TestLocalHubConnect().
List<string> DCPlusPlus.Hub.user_list = new List<string>() [protected] |
| event UserJoinedEventHandler DCPlusPlus.Hub.UserJoined |
Event handler that gets called when a user joined a hub.
Definition at line 93 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), and DCPlusPlus.Hub.Copy().
| event UserQuitEventHandler DCPlusPlus.Hub.UserQuit |
Event handler that gets called when a user was disconnected from a hub.
Definition at line 82 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), and DCPlusPlus.Hub.Copy().
long DCPlusPlus.Hub.users = 0 [protected] |
string DCPlusPlus.Hub.Address [get, set] |
the hub address
Definition at line 312 of file Hub.cs.
Referenced by DCPlusPlus.Queue.AddFileList(), DCPlusPlus.HubList.ReadHub(), and DCPlusPlus.Hub.TestLocalHubConnect().
bool DCPlusPlus.Hub.AutoReconnect [get, set] |
List<ChatLine> DCPlusPlus.Hub.ChatHistory [get, set] |
int DCPlusPlus.Hub.ChatHistoryMaxLength [get, set] |
string DCPlusPlus.Hub.Country [get, set] |
the country in which the hubs resides in
Definition at line 363 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
string DCPlusPlus.Hub.Description [get, set] |
the hub description
Definition at line 348 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
bool DCPlusPlus.Hub.IsGrabbedByClient [get, set] |
TRUE if a client has added some event handlers to this hub.
Definition at line 483 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub(), and DCPlusPlus.Hub.TestLocalHubConnect().
bool DCPlusPlus.Hub.IsLoggedIn [get] |
int DCPlusPlus.Hub.MaxHubs [get, set] |
the maximum number of hubs a client can be connected to to connect to this hub
Definition at line 440 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
long DCPlusPlus.Hub.MaxUsers [get, set] |
the maximum number of users this hub supports
Definition at line 455 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
long DCPlusPlus.Hub.MinShare [get, set] |
the minimum amount of shared bytes a client needs to connect to this hub
Definition at line 410 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
int DCPlusPlus.Hub.MinSlots [get, set] |
the minimum amount of open slots a client needs to connect to this hub
Definition at line 425 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
ConnectionMode DCPlusPlus.Hub.MyConnectionMode [get, set] |
the connection mode to use on this hub this will decide how to connect to peers active or passive
Definition at line 849 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyConnectionSpeed [get, set] |
the connection speed of the client pc to the internet
Definition at line 815 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyDescription [get, set] |
the user description
Definition at line 696 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyEmail [get, set] |
the email address of the user
Definition at line 681 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyIP [get, set] |
set it to the external ip of the client pc it will we used for active connection requests
Definition at line 621 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyName [get, set] |
the name of the client
Definition at line 666 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
long DCPlusPlus.Hub.MyShareSize [get, set] |
the total number of shared bytes by the client
Definition at line 711 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyTagVersion [get, set] |
the version of the client that is used in the myinfo tag
Definition at line 651 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
int DCPlusPlus.Hub.MyTcpPort [get, set] |
the local tcp port used by the client to accept remote connections
Definition at line 727 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
int DCPlusPlus.Hub.MyUdpPort [get, set] |
the local udp port used by the client to receive udp search results
Definition at line 743 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.MyVersion [get, set] |
the version of the client
Definition at line 636 of file Hub.cs.
Referenced by DCPlusPlus.Client.ConnectHub().
string DCPlusPlus.Hub.Name [get, set] |
the hub name
Definition at line 297 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub(), and DCPlusPlus.ListeningSockets.SearchReply().
List<string> DCPlusPlus.Hub.OperatorList [get, set] |
long DCPlusPlus.Hub.Shared [get, set] |
the number of shared bytes on the hub
Definition at line 395 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
List<string> DCPlusPlus.Hub.UserList [get, set] |
the users connected to this hub (Todo change this to a enumeration at the moment it can throw list modified exceptions)
Definition at line 587 of file Hub.cs.
Referenced by DCPlusPlus.Hub.Copy(), and DCPlusPlus.Client.UpdateSourcesByHub().
long DCPlusPlus.Hub.Users [get, set] |
the number of users connected to the hub (as replied from a hublist) TODO support returning of UserList.Count
Definition at line 380 of file Hub.cs.
Referenced by DCPlusPlus.HubList.ReadHub().
1.5.1-p1