I want to send data from node.js to C# -



I want to send data from node.js to C# -

i work on asterisk ami node.js server want send info [node.js server] c# client in real time server.js

var app = require('http').createserver().listen(3001); var io = require('socket.io').listen(app); var asteriskami = require('asterisk-ami'); var ami = new asteriskami( { host: '127.0.0.1', username: 'admin', password: '123456' } ); io.sockets.on('connection', function(socket) { socket.emit('notification', {message: "connected"}); }); ami.on('ami_data', function(data) { io.sockets.emit('ami_event', data); // or same // io.emit('ami_event', data); }); ami.connect(function(){ });

c# sharp client using system; using system.io; using system.net; using system.net.sockets; using system.text;

class mytcplistener { public static void main() { tcplistener server = null; seek { // set tcplistener on port 13000. int32 port = 3001; ipaddress localaddr = ipaddress.parse("127.0.0.1"); // tcplistener server = new tcplistener(port); server = new tcplistener(localaddr, port); // start listening client requests. server.start(); // buffer reading info byte[] bytes = new byte[256]; string info = null; // come in listening loop. while (true) { console.write("waiting connection... "); // perform blocking phone call take requests. // user server.acceptsocket() here. tcpclient client = server.accepttcpclient(); console.writeline("connected!"); info = null; // stream object reading , writing networkstream stream = client.getstream(); int i; // loop receive info sent client. while ((i = stream.read(bytes, 0, bytes.length)) != 0) { // translate info bytes ascii string. info = system.text.encoding.ascii.getstring(bytes, 0, i); console.writeline("received: {0}", data); // process info sent client. info = data.toupper(); byte[] msg = system.text.encoding.ascii.getbytes(data); // send response. stream.write(msg, 0, msg.length); console.writeline("sent: {0}", data); } // shutdown , end connection //client.close(); } } grab (socketexception e) { console.writeline("socketexception: {0}", e); } { // stop listening new clients. server.stop(); } console.writeline("\nhit come in continue..."); console.read(); } }

c# node.js sockets

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -