GithubHelp home page GithubHelp logo

xpush / lib-xpush-web Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 1.0 608 KB

Javascript library for XPUSH Server

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

License: MIT License

JavaScript 91.95% CSS 0.71% HTML 7.34%

lib-xpush-web's Introduction

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.

lib-xpush-web's People

Contributors

0nlyoung7 avatar johnkim avatar notdol avatar

Stargazers

Sleepyy.Net avatar  avatar  avatar Jeongbu Yoon avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

onjsdnjs

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.