This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet, sys | |
from eventlet.green import socket, zmq | |
from eventlet.hubs import use_hub | |
use_hub('zeromq') | |
ADDR = 'ipc:///tmp/chat' | |
ctx = zmq.Context() | |
def publish(writer): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from zmq import FORWARDER, PUB, SUB, SUBSCRIBE | |
from zmq.devices import Device | |
if __name__ == "__main__": | |
usage = 'usage: chat_bridge pub_address sub_address' | |
if len (sys.argv) != 3: | |
print usage | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************************************** | |
** Copyright (C) 2010 Movid Authors. All rights reserved. | |
** | |
** This file is part of the Movid Software. | |
** | |
** This file may be distributed under the terms of the Q Public License | |
** as defined by Trolltech AS of Norway and appearing in the file | |
** LICENSE included in the packaging of this file. | |
** | |
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <strings.h> | |
#include <stdint.h> | |
std::string hexDump( const zmq::message_t & aMessage, num = 0 ) { | |
// I'm going to build a hex/ascii dump like you've seen so many times before | |
std::string msg; | |
std::string ascii; | |
// get the pointer to the start of the message's payload - and it's size | |
const char *buff = (const char *)aMessage.data(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from datetime import datetime | |
from eventlet.green import zmq | |
from eventlet.hubs import use_hub | |
use_hub('zeromq') | |
def transmit(): | |
context = zmq.Context() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zombie = require "zombie" | |
testCase = require("nodeunit").testCase | |
_ = require "underscore" | |
tests = | |
setUp: (cb) -> | |
zombie.visit "http://localhost:<port>/websocket_page_url/", {debug: false}, (err, browser, stat) -> | |
@browser = browser | |
# Set sensible timout for initial page set up to be done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from eventlet.pools import Pool | |
class SocketPool(Pool): | |
"""A pool of sockets connected to a component | |
If a socket times out in use, simply close if before handing it back to the | |
pool and it will be discarded and a replacement inserted into the pool. | |
""" | |
def __init__(self, address, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Component(object): | |
def _setup_sockets(self): | |
pub_address = "tcp://whatever..." | |
ext_socket = ctx.socket(zmq.PUB) | |
ext_socket.bind(pub_address) | |
self.internal_addr = "inproc://my_pub" | |
int_socket = ctx.socket(zmq.PULL) | |
int_socket.bind(self.internal_addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveDataTypeable #-} | |
module Main where | |
{- | |
Example FRP/zeromq app. | |
The idea is that messages come into a zeromq socket in the form "id state". The state is of each id is tracked until it's complete. | |
-} | |
import Control.Monad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet import wsgi | |
from paste.httpserver import serve | |
from pyramid.config import Configurator | |
from pyramid.response import Response | |
from pyramid.view import view_config | |
from stargate import WebSocketAwareResource, WebSocketView, is_websocket | |
import simplejson as json | |
host = "127.0.0.1" |
OlderNewer