A simple Go based IM system. The Project is based on Go 1.3.1 currently. Has Tested onGo 1.4.1.
- Install Golang to your computer,
- Checkout the project,
- Go to the project folder and run
go run imServer.go
to start the server.
The default port is 9000 (e.g. entry: localhost:9000/), can be changed in imServer.go.
The login services is not implemented yet.
Currently, the project has not connect to any database but will in the future.
Todo: need do a sh file for compile project and run (a easy way to run)!
![Image of goTalk arch](https://github.com/alvindaiyan/goTalk/blob/master/config/goTalk Arch v0.png) The user can has two role in this simple IM system. One is the sender, and one is the receiver. Each user has a channel to store message. goTalk is designed to obtain the http transfer standard.
This section will introduce the message sending process of the goTalk. The service name is send
, requires FOUR parameters and is a POST method. The three params are the Token
, the id
(send user), the username
(senduser) the sendTo
(user id of the receiver) and the message content
. (After checking the validability of the token) When a message is sent, the server firstly receive the message and parse to a User object and a Message object. A receive message will be send back. Then the server find the channel regarding of the receive user's id and add to it. If the receiver Id is valid but there is not a channel for it, a new channel will be created and added to the appConfig. An example ajax call is:
$.post('/send',
{
username: username,
id: id,
sendToId: sendToId,
content: content
}, function(data) {
// data is in Json format
...
});
There is a map to store all the message channel and indexed by the user id. When the server receive a request to sync the user's message status, the services name is sync
, require two params: Token
, id
(user id). The message will be dequeue from the channel and pass back to the user as Json string.
Problem: The message could be lost if the message is not successfully send at first time. need to be fixed!
Currently, using AES256.