ushtabalakh
Programmer
- Jun 4, 2007
- 132
Hi
I have a project in which I need to develop different kinds of servers (TCP listeners). Since we are going to do it remotely I thought it's a good idea to prepare an interface that all programmers would implement when they are coding.
This would help us have more unified codes.
Here is the interface I prepared:
Do you see anything that is lacking? Do you think this is a good way of doing things? ANY criticism is highly welcomed.
Thanks.
I have a project in which I need to develop different kinds of servers (TCP listeners). Since we are going to do it remotely I thought it's a good idea to prepare an interface that all programmers would implement when they are coding.
This would help us have more unified codes.
Here is the interface I prepared:
Code:
''' <summary>
''' All servers should implement this interface and they should NOT have any public methods other than the ones used here.
''' </summary>
''' <remarks></remarks>
Public Interface ServerInterface
#Region "Enum Definitions"
''' <summary>
''' Shows whether the server has started or not.
''' </summary>
''' <remarks></remarks>
Enum serverStatusItems
Stopped
Started
End Enum
''' <summary>
''' Shows whether a client is currently connected to the server or not.
''' </summary>
''' <remarks></remarks>
Enum connectionStatus
clientConnected
clientNotConnected
End Enum
#End Region
#Region "Server Status"
''' <summary>
''' Starts server on the given port and waits for a client with the given IP address to connect.
''' </summary>
''' <param name="port">The port number on which server should listen</param>
''' <param name="clientIP">The only client IP address that will be able to communicate with this server</param>
''' <returns>True of everything is successfull and False if the server could get started.</returns>
''' <remarks></remarks>
Function startServer(ByVal port As Integer, ByVal clientIP As System.Net.IPAddress) As Boolean
''' <summary>
''' Restarts the server with previously given parameters when startServer was called
''' </summary>
''' <remarks></remarks>
Sub restartServer()
''' <summary>
''' Disconnects the currently connected client and stops listening for a new client to connect.
''' </summary>
''' <remarks></remarks>
Sub stopServer()
''' <summary>
''' Returns a value indicating whether the sever is started or stopped
''' </summary>
''' <returns>A value of serverStatusItems kind</returns>
''' <remarks></remarks>
Function serverStatus() As serverStatusItems
''' <summary>
''' Returns a value indicating whether there is a client connected to this server or not
''' </summary>
''' <returns></returns>
''' <remarks>a value of connectionStatus</remarks>
Function serverConnectionStatus() As connectionStatus
#End Region
#Region "Connectivity"
''' <summary>
''' Disconnects the current user.
''' </summary>
''' <remarks></remarks>
Sub disconnectUser()
''' <summary>
''' Used to make sure client is still connected and alive
''' When called, this function should say "hi" to the client and client should respond "Hi IPADDRESSOFSERVER"
''' </summary>
''' <returns>True if client does so, and retuns false if it doesn't</returns>
''' <remarks></remarks>
Function greetClient() As Boolean
#End Region
#Region "Properties"
''' <summary>
''' Sets all the properties that the server may ever need in order to function
''' </summary>
''' <param name="Properties">Properies entered in a HashTable</param>
''' <remarks></remarks>
Sub SetProperties(ByVal Properties As Hashtable)
''' <summary>
''' Returns all the properties that the server is currently using.
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Function getProperties() As Hashtable
#End Region
End Interface
Do you see anything that is lacking? Do you think this is a good way of doing things? ANY criticism is highly welcomed.
Thanks.