ajaxssesocket's People
ajaxssesocket's Issues
Socket#emit(name:String[, ...]):Socket
Emits an event to the socket identified by the string name
. Any other parameters can be included.
All datastructures are supported, including `Buffer. JavaScript functions can't be serialized/deserialized.
var io = require('socket.io')();
io.on('connection', function(socket) {
socket.emit('an event', { some: 'data'});
});
cache javascript for client-side
I want that to cache javascript (index.js) on request
find info on require.resolve
windows/linux url
Find a correct os independent way to create paths
Socket#join(name:String[, fn:Function]):Socket
Adds the socket to the room
, and fires optionally a callback fn
with err
signature (if any).
The socket is automatically a member of a room identified with its session id (see Socket#id
).
The mechanics of joining rooms are handled by the Adapter
that has been configured (see Server#adapter
above), defaulting to socket.io-adapter.
big javascript files
I must not depend of volume of js file prepared for send
Server#serveClient(v:Boolean):Server
if v
is true
the attached server (see Server#attach
) will serve the clients files. Defaults to true
.
This method has no effect after attach
is called.
//pass a server ad the `serveClient` option
var io = require('socket.io')(http, { serveClient: false});
//or pass no server and then you can call the method
var io = require('socket.io')();
io.serveClient(false);
io.attach(http);
If no arguments are supplied this method returns the urrent value.
Server#sockets:Namespace
The default ( / ) namespace.
Server()
Creates a new Server
. Works with and without new
:
var io = require('socket.io')();
//or
var Server = require('socket.io');
var io = new Server();
Namespace
Represents a pool of sockests connected under a given scope identified by a pathname (eg: /chat
).
By default the client always connects to /
.
Namespace#events - connection/connect
Fired upon a connection. Parameters: socket
the incoming socket
Socket#client:Client
A reference to the underlying Client
object.
minify function
create a github project wich will give you the possiblitiy to minify javascript.
Socket#rooms:Array
A list of strings identifying the rooms this socket is in
Server#adapter(v:Adapter):Server
Sets the adapter v
. Defaults to an instance of the Adapter
that ships with socket.io which is memory based. Se socket.io-adapter.
If no arguments are suppliet this method returns the current value.
Socket#request:Request
A getter proxy that returns the reference to the request
that originated the underlying engine.io Client
. Useful for accessing request headers such as Cookie
or User-Agent
Server
Exposed by require('socket.io')
add winston logger
Namespace#connected:Object
Hash of Socket
objects that are connected to this naespace indexed by id
Server(port:Number)
Binds socket.io to a new http.Server
that listens on port
Server#attach(srv:http#Server, opts:Object):Server
Attaches the Server
to an engine.io instance on srv
with the supplied opts
(optionally)
Socket
A Socket
is the fundamental class for interacting with browser clients. A Socket
belongs to a certains Namespace
(by default /
) and uses an underlying Client
to communicate.
Server#listen
Synonym of Server#attach
Namespace#name:String
The namespace identifier property
check if port is free and if not show the processes which trap it
create git link to ajaxSSEsocket-client library
Server#path(v:String):Server
Sets the path v
under which engine.io
and the satic files will be served. Defaults to /socket.io
If no arguments are supplied this method returns the current value.
server connection like socket.io server
socket.io server have two different approach when is instantiate
- it is attached to an http server
var http = require('http');
var app = http.createServer(handler);
app.listen(8080)
var io = require('socket.io')(app)
- or it create a server on port
var io = require('socket.io')(8080)
- or
var IoServer = require('socket.io')
var io = IoServer.listen(8080)
- or
var IoServer = require('socket.io')
var io = new IoServer(8080)
Implement this behaviour. hint:
function Server() { ... }
Server.prototoype.listen = Server;
Server(srv:http#Server)
Creates a new Server
and attaches it to the given srv
. Optionally opts
can be passed
Client#conn
A reference to the underlying engine.io Socket
connection
Socket#to(room:String):Socket Socket#in(room:String):Socket
Sets a modifier for a subsequent event emission that the event will only be broadcasterd
to sockets that have joined the given room
.
To emit to multiple rooms, you can call to
several times.
var io = require('socket.io')();
io.on('connection', function(socket) {
socket.to('others').emit('an event', { some: 'data'});
});
Server#onconnection(socket:engine#Socket):Server
Advanced use only. Creates a new socket.io
client from the incoming engine.io (or compatible AP) socket
Socket#leave(name:String[, fn:Function]):Socket
Removes the socket from room
, and fires optionally a callback fn
with err
signature (if any)
Rooms are left autmoatically upon disconnection.
The mechanics of leaving rooms are handled by the Adapter
that has been configured (see Server#adapter
above), defaulting to socket.io-adapter
Server#user
See Namespace#use
below
Server#of(nsp:String):Namespace
Initializes and retrieves the given Namespace
by its pathname identifier nsp
.
If the namespace was already initialized it returns it right away.
Socket#conn:Socket
a reference to the underlying Client
transport connection (engine.io Socket
object)
add port range in server instantiation
port must be in [0โ65535] range
Socket#id:String
A unique identifier for the socket session, that comes from the underlying Client
Server#bind(srv:engine#Server):Server
advanced use only. Binds the server to a specific engine.io Server
(or compaticle API) instance
Namespace#use(fn:Function):Namespace
Registes a middleware, which is a function that gets executed for every incoming Socket
and receives as parameter the socket and a function to optionally defer execution to the next registered middleware
var io = require('socket.io')();
io.use(function(socket, next) {
if(socket.request.headers.cookie) return next();
next(new Error('Authentication error'));
});
Errors passed to middleware callbacks are sent as special error
packets to clients
Server#attach(port:Number, opts:Object):Server
Attaches the Server
to an engine.io instance that is bound to port
with the given opts
(optionally)
Server#emit
Emits an event to all connected clients. The following two are equivalent:
var io = require('socket.io')();
io.sockets.emit('an event sent to all connected clients');
io.emit('an event sent to all connected clients');
For other available methods, see Namespace
below
Client
The Client
class represnts an incoming transport (engine.io) connection. A Client
ca be associated with many multiplexed Socket
that belong to different Namespace
s
Client#request
A getter proxy that returns the reference tho the request
that originated the engine.io connection. Useful for accesing request headers such as Cookie
or User-Agent
.
Server(opts: Object)
Optionally, the first or second argument see bellow) of the Server
constructor cab be an options object.
The following options are supported:
serveClient
sets the value forServer#serveClient()
path
setsh the value forServer#path()
The same options passed to socket.io are always passed to the engine.io Server
that gets created. See engine.io options as reference.
Server#origins(v:String):Server
Sets the allowed origins v
. Defaults to any origiins being allowed.
If no arguments are supplied this method returns the current value.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.