Giter Club home page Giter Club logo

netty_push_server's Introduction

Netty Push Server

The Netty Push Server Framework contains Netty Server (SQL script) 、Java SDK and Android SDK 。The iOS SDK is developing!

Based Netty-4.0.23.Final + Spring build the Netty Push Server Framework!Already through simple test,and it work's good。You can use Java SDK in your owner server,it will get from the jar folder . Also you can use Android SDK for your mobile development,it used very easy and simple!You can get it from the anetty_client project!

Before you start ,must choose an oracle database for your server,and import the SQL script. Other database is developing!You can develop it yourself with your own database,only create a Java File in server project,in the package:com.netty.push.dao,and used another spring annotate for @Service("your named")。

COMPILE & BUILD

You can used ant to compile & build the Netty Server,the build.xml is created in the root folder. If your computer is Windows Operating System you can run start.bat with the Ant Environment is configed.Last will create two jars:netty_push_server.jar & netty_server_sdk.jar in the jar folder。

netty_push_server.jar——The Push Server Library .That You can put in your self Web Project with support spring,and must load sping-context.xml in the web.xml。

netty_server_sdk.jar ——Your Server SDK Library .You can import the jar in your self project to send push message!

HOW TO START?

There are two kinds of methods:

1.Use nettyServer.start() to run the push server in a suitable place of your project. For example:In the Application ServletContextListener. The nettyServer defined in spring-context.xml.

2.Use command line: java -jar netty_push_server.jar spring-context.xml to run the push server independent startup. Above all , you must ensure that contains the libs's jars in the classpath!

HOW USED JAVA SDK?

Java Server SDK:jar/netty_server_sdk.jar

Java Server SDK Example:

import java.util.ArrayList; import java.util.List;

import com.netty.push.sdk.client.NettyClient; import com.netty.push.sdk.client.listener.INettyClientHandlerListener; import com.netty.push.sdk.pojo.Message; import com.netty.push.sdk.pojo.MessageResult;

public class Test {

/**
 * @param args
 */
public static void main(String[] args) {		
	//netty server ip
	String ip = "127.0.0.1";
	//netty server port
	int port = 6319;
	//create NettyClient with ip & port
	NettyClient nettyClient = NettyClient.getInstance(ip, port);
	//new Message Object
	Message message = new Message();
	//set app key
	message.setAppKey("5E4283368424E24641B990631988EE2C");
	//true:all devices can received    false:the message.devices can received
	message.setAllPush(false);
	//message title
	message.setTitle("test title");
	//message content 
	message.setContent("test content");
	//offline device is show or not
	message.setOfflineShow(true);
	//true: after terminal received the message it will send a receipt message to server
	message.setReceipt(true);
	//set message devices
	List<String> list = new ArrayList<String>(); 
	list.add("1800E6B16E5F77B4EE9747B1904F1F90");
	message.setDevices(list);		
	try {
		//send message method 
		//INettyClientHandlerListener is callback listener which tell you the sended message's status
		nettyClient.sendMessage(message, new INettyClientHandlerListener() {

			@Override
			public void receive(MessageResult result) {
				System.out.println("come in");
				if (result != null) {
					System.out.println(result.getMsgId() + "-" + result.isSuccess());
				}
			}
		});
	} catch (Exception e) {
		e.printStackTrace();
	}

}

}

netty_push_server's People

Contributors

maofw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.