Requirements:
- Chat two customers
- Group talk
- Receive offline messages
- Preservation of history (actually, follows from the third paragraph)
- Requirements that are not related to the question: registration, authorization through third-party services (google, ms live), the user can specify additional. information about yourself, receiving / transmitting files directly between clients and through the server.
The task as a whole is of sports interest. Suppose that customers will be up to 10k, the application itself will develop and will need to be supported.
I can not decide how to make it more convenient:
- Poll server constantly for changes
- Maintain a permanent socket connection
The problems with the first option are very resource intensive. Each request must be validated, frequent access to the database.
The second option is difficult to implement and support. Actually, there is such an idea: deploy a wcf-service, send messages through it (like a SendMessage(message, userId)
). In addition, provide also a connection point to the socket, which already deliver this message to the recipient.
That is, the client's actions: logged in -> connected to the socket -> sent a message through the wcf-service
wcf-service: received a message -> found the "socket-connection" of the recipient -> sent a message via tcp
Actually, what is easier to maintain and what is “cheaper” - thousands of TCP connections or thousands of thousands of requests to the server?
Thank you very much in advance!
ps. you probably shouldn't offer the state connection of a wcf service. The end client should work on several platforms + I have read a lot of bad things about them.