IM server based on netty. Provides a client jar. Integrate with your own login system.基于netty实现的IM服务端,提供客户端jar包,可集成自己的登录系统
IM is a lightweight instant messaging server. It also provides a client jar,allows you to develop your own client.For example,with spring boot. It's able to login with your own login system or with ldap.
We use docker to quick start IM.
# detect if the docker environment is avaliable.
docker -v# clone the repository
git clone [email protected]:yuanrw/IM.gitcd IM/docker
docker-compose upThere is a simple sample in the container,it starts serveral clients and send messages to their friends randomly,printing logs which are similar with followed:
…mvn clean package -DskipTestsget $SERVICE_NAME-$VERSION-bin.zip under dir /target
Start services with the following order: rest-web --> transfer -->connector
Here are the steps for start rest-web,transfer and connector are similar with it.
unzip rest-web-$VERSION-bin.zip
cd rest-web-$VERSIONserver.port=8082
# your log path
log.path=
# your jdbc config
spring.datasource.url=
......
# your redis config
spring.redis.host=
......
# your rabbitmq config
spring.rabbitmq.host=
......run the sql in the file rest.sql
start server
java -jar rest-web-$VERSION.jar --spring.config.location=application.propertiesjava -jar -Dconfig=transfer.properties transfer-$VERSION.jarjava -jar -Dconfig=connector.properties connector-$VERSION.jarAll services are available to expand horizontally,connections need to be kept alive between each client and connector server. A sample nginx config:
stream {
upstream backend {
# connector services port
server 127.0.0.1:9081 max_fails=3 fail_timeout=30s;
server 127.0.0.1:19081 max_fails=3 fail_timeout=30s;
}
server {
# to keep a persistent connection
listen 9999 so_keepalive=on;
proxy_timeout 1d;
proxy_pass backend;
}
}There is a simple usable login system in IM. IM also support the following two ways to authenticate.
We use open ldap as an example. update application.properties
spi.user.impl.class=com.yrw.im.rest.web.spi.impl.LdapUserSpiImpl
# the following config should be replace with your own config
spring.ldap.base=dc=example,dc=org
# admin
spring.ldap.username=cn=admin,dc=example,dc=org
spring.ldap.password=admin
spring.ldap.urls=ldap://127.0.0.1:389
# user filter,use the filter to search user when login in
spring.ldap.searchFilter=
# search base eg. ou=dev
ldap.searchBase=
# user objectClass
ldap.mapping.objectClass=inetOrgPerson
ldap.mapping.loginId=uid
ldap.mapping.userDisplayName=gecos
ldap.mapping.email=mailjava -jar rest-web-$VERSION.jar --spring.config.location=application.propertiescom.yrw.im.rest.spi.UserSpipublic interface UserSpi {
/**
* get user by username and password, return user(id can not be null)
* if username and password are right, else return null.
*
* be sure that your password has been properly encrypted
*
* @param username
* @param pwd
* @return
*/
T getUser(String username, String pwd);
/**
* get user by id, if id not exist then return null.
*
* @param id
* @return
*/
T getById(String id);
}# your implement class full name
spi.user.impl.class=mvn clean package -DskipTestsA client demo:
No open issues yet, or sync has not completed.