Skip to content

xpush/lib-xpush-web

Repository files navigation

xpush javascript library

The simplest way to develop real-time web communication on web browsers.

  • The project is currently under development. Not yet available.

Built with Grunt

Install

Just add script in your web page : Download the production version.

<script src="xpush.min.js"></script>

Getting Started

In your web page:

Data send

<script>
  var xpush1 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  xpush1.login('userid1','password',function(){ 
      xpush1.send('channelname','message',data); 
  }); 
</script>

Other user receive data

<script>
  var xpush2 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  xpush2.login('userid2','password',function(){
    xpush2.on('message',function(channel, name, data){
      // channel is channelname, name is key, data is data!
    });
  });
</script>

Documentation

http://xpush.github.io/doc/library/javascript/

Examples

message send

Use XPush Object! But you must know your target channel name;

<script>
  var xpush1 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  xpush1.login('userid1','password',function(){
      xpush1.send('channelname','message',data);
  });
</script>

Channel Create & Use Channel Object

<script>
  var xpush2 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  
  xpush2.login('userid2','password',function(){
    var channel = xpush2.createChannel([userid1, userid2 ...], /*channelName(option),*/ function(err, channelName){

      });
    channel.send('message',data);
  });
</script>

receive message

<script>
  var xpush3 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  
  xpush3.login('userid3','password',function(){
    xpush3.on('message',function(channelname, name, data){
      // read unreadmessages & ready to receive messages
    });
  });
</script>

create channel

<script>
  var xpush4 = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  
  xpush4.login('userid4','password',function(){
    var channel = xpush4.createChannel([userid1, userid2 ...], /*channelName(option),*/ function(err, channelName){

      });
  });
</script>

create channel event

<script>
  var xpush = new XPush('http://demo.stalk.io:8000', 'APP_ID');
  
  xpush.login('userid','password',function(){
    xpush.on('newchannel',function(chnnelObject){
      // channelname is : channelObject.chNm
    });
  });
</script>

License

xpush libraries may be freely distributed under the MIT license.

About

Javascript library for XPUSH Server

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •