All Projects → minaandrawos → machat

minaandrawos / machat

Licence: MIT license
An open source chat server implemented in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to machat

Netcoreserver
Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 799 (+994.52%)
Mutual labels:  websocket-server, tcp-server, tcp-client
Socketify
Raw TCP and UDP Sockets API on Desktop Browsers
Stars: ✭ 67 (-8.22%)
Mutual labels:  websocket-server, tcp-server, tcp-client
Cppserver
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 528 (+623.29%)
Mutual labels:  websocket-server, tcp-server, tcp-client
SuperSimpleTcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 263 (+260.27%)
Mutual labels:  tcp-server, tcp-client
Rockgo
A developing game server framework,based on Entity Component System(ECS).
Stars: ✭ 532 (+628.77%)
Mutual labels:  websocket-server, tcp-server
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+7324.66%)
Mutual labels:  websocket-server, tcp-server
Nano
Lightweight, facility, high performance golang based game server framework
Stars: ✭ 1,888 (+2486.3%)
Mutual labels:  websocket-server, tcp-server
Mongols
C++ high performance networking with TCP/UDP/RESP/HTTP/WebSocket protocols
Stars: ✭ 250 (+242.47%)
Mutual labels:  websocket-server, tcp-server
cAndroid
cAndroid is tool for control your PC by Android phone
Stars: ✭ 23 (-68.49%)
Mutual labels:  tcp-server, tcp-client
QTcpSocket
A simple Qt client-server TCP architecture to transfer data between peers
Stars: ✭ 62 (-15.07%)
Mutual labels:  tcp-server, tcp-client
chat-app
Multithreading TCP server and client communicating over TCP/IP - Windows Forms Application.
Stars: ✭ 39 (-46.58%)
Mutual labels:  tcp-server, tcp-client
rockgo
A developing game server framework,based on Entity Component System(ECS).
Stars: ✭ 617 (+745.21%)
Mutual labels:  websocket-server, tcp-server
Easyswoole
swoole,easyswoole,swoole framework
Stars: ✭ 4,409 (+5939.73%)
Mutual labels:  websocket-server, tcp-server
trellio
Python3 asyncio based microframework for microservice architecture
Stars: ✭ 19 (-73.97%)
Mutual labels:  tcp-server, tcp-client
cs
开箱即用的基于命令的消息处理框架,让 websocket 和 tcp 开发就像 http 那样简单
Stars: ✭ 19 (-73.97%)
Mutual labels:  websocket-server, tcp-server
tcp-net
Build tcp applications in a stable and elegant way
Stars: ✭ 42 (-42.47%)
Mutual labels:  tcp-server, tcp-client
Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (+124.66%)
Mutual labels:  tcp-server, tcp-client
Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+3131.51%)
Mutual labels:  tcp-server, tcp-client
Socket-Programming-With-C
✉️ Learn Network Protocol and Network Programming
Stars: ✭ 147 (+101.37%)
Mutual labels:  tcp-server, tcp-client
AsyncTcpClient
An asynchronous variant of TcpClient and TcpListener for .NET Standard.
Stars: ✭ 125 (+71.23%)
Mutual labels:  tcp-server, tcp-client

MaChat


MaChat in action

An open source chat server implemented in pure Go. The chat server listens on a TCP port and/or a websocket. It supports the following concepts:

  • Chat clients: A chat client represents the person who is sending and receiving messages
  • Chat rooms: A chat room is a place where multiple chat clients can be added. All clients connected to the same chat room will be able to see their messages

Pull requests are more than welcome


How it works?

  • The MaChat server listens on a TCP server as well as a websocket server specified by you for incoming messages
  • A MaChat client starts the connection by:
    • Establishing a TCP or a websocket connection to the MaChat server port
    • Sending a JSON string message to indicate that chat client name as well as the name of the chat room that the client would like to join. The JSON format looks like this: {"name": "Mina", "room":"devroom"}
    • Chat rooms can be shared between TCP clients and websocket clients based on how the chat API is initialized

Once the name and chat room is sent to the chat server, the client can then proceed to send string messages via TCP or websockets, the server will route the messages to the appropriate chat room and share them with other clients in the chat room.


How to run the server?

The MaChat server supports two user flags:

  • '-tcp' which is used to indicate the TCP server listening address. The default value is "localhost:8989"
  • '-ws' which is used to indicate the websocket server listening address. The default value is "localhost:8099"

Example command:

<executablename> -tcp localhost:8989 -ws localhost:8099

'executablename' here is the name of the executable you build for the chat server. If you would like to run the code directly from the go code:

#Run the chat server with the default port
go run cmd/machat/machat.go

There is an example TCP chat client application code provided which supports three user flags:

  • '-client' : for client name
  • '-room': for chat room name
  • '-address': for the TCP address of the chat server, defaulted to localhost:8989

To run the example client application with client name 'Mina' and chat room 'dev':

go run cmd/examplechatclient/chattcpclient.go -client Mina -room dev

There is also an example for a websocket client application which supports four user flags:

  • '-client' : for client name
  • '-room': for chat room name
  • '-origin': for origin header field of the websocket
  • '-address': for the TCP address of the chat server, defaulted to localhost:8099

What's checked in?

  • ./gotcpchat.go: entry point to the chat TCP server code
  • ./gowschat.go: entry point to the chat websocket server code
  • ./chatapi/clients.go: code to handle the chat clients, the code is exposed as an API to be used by gotcpchat.go
  • ./chatapi/rooms.go: code to handle chat rooms, the code is exposed as an API to be used by gotcpchat.go
  • ./cmd/machat/machat.go: main package for the MaChat TCP server, you need to build this file to get the executable for the chat server
  • ./cmd/examplechatclients/chattcpclient.go: main package for an example tcp client that can connect to the chat server
  • ./cmd/examplechatclients/chatwebsocketclient.go: main package for an example tcp client that can connect to the chat server

For other articles and tutorials, check my website at www.minaandrawos.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].