Push notification via C# socket
up vote
0
down vote
favorite
I want to send push notifications via C# socket server to React Native. On react native side, I use socket.io. React Native connects to the server, but never receives a message back.
React Native code:
socket = io.connect('xx.xx.xx.xx:2201');
socket.on((messages) => {
console.log("response" + JSON.stringify(messages));
});
Server Code:
public static void StartListening()
{
byte bytes = new Byte[1024];
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
/
Socket listener = new Socket(ipAddress.AddressFamily,SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);
listener.Listen(10);
while (true)
{
Socket handler = listener.Accept();
data = null;
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
Console.WriteLine("Receieved message and sent: " + data);
byte msg1 = Encoding.ASCII.GetBytes("jjjjjj");
handler.Send(msg1);
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
Console.WriteLine("nPress ENTER to continue...");
Console.Read();
}
c# react-native socket.io
add a comment |
up vote
0
down vote
favorite
I want to send push notifications via C# socket server to React Native. On react native side, I use socket.io. React Native connects to the server, but never receives a message back.
React Native code:
socket = io.connect('xx.xx.xx.xx:2201');
socket.on((messages) => {
console.log("response" + JSON.stringify(messages));
});
Server Code:
public static void StartListening()
{
byte bytes = new Byte[1024];
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
/
Socket listener = new Socket(ipAddress.AddressFamily,SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);
listener.Listen(10);
while (true)
{
Socket handler = listener.Accept();
data = null;
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
Console.WriteLine("Receieved message and sent: " + data);
byte msg1 = Encoding.ASCII.GetBytes("jjjjjj");
handler.Send(msg1);
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
Console.WriteLine("nPress ENTER to continue...");
Console.Read();
}
c# react-native socket.io
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to send push notifications via C# socket server to React Native. On react native side, I use socket.io. React Native connects to the server, but never receives a message back.
React Native code:
socket = io.connect('xx.xx.xx.xx:2201');
socket.on((messages) => {
console.log("response" + JSON.stringify(messages));
});
Server Code:
public static void StartListening()
{
byte bytes = new Byte[1024];
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
/
Socket listener = new Socket(ipAddress.AddressFamily,SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);
listener.Listen(10);
while (true)
{
Socket handler = listener.Accept();
data = null;
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
Console.WriteLine("Receieved message and sent: " + data);
byte msg1 = Encoding.ASCII.GetBytes("jjjjjj");
handler.Send(msg1);
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
Console.WriteLine("nPress ENTER to continue...");
Console.Read();
}
c# react-native socket.io
I want to send push notifications via C# socket server to React Native. On react native side, I use socket.io. React Native connects to the server, but never receives a message back.
React Native code:
socket = io.connect('xx.xx.xx.xx:2201');
socket.on((messages) => {
console.log("response" + JSON.stringify(messages));
});
Server Code:
public static void StartListening()
{
byte bytes = new Byte[1024];
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
/
Socket listener = new Socket(ipAddress.AddressFamily,SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);
listener.Listen(10);
while (true)
{
Socket handler = listener.Accept();
data = null;
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
Console.WriteLine("Receieved message and sent: " + data);
byte msg1 = Encoding.ASCII.GetBytes("jjjjjj");
handler.Send(msg1);
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
Console.WriteLine("nPress ENTER to continue...");
Console.Read();
}
c# react-native socket.io
c# react-native socket.io
edited yesterday
asked yesterday
dummy
6418
6418
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Maybe this is help you.
import SocketIOClient from 'socket.io-client';
this.socket = SocketIOClient('xx.xx.xx.xx:2201', {
transports: ['websocket']
});
this.socket.on('message', (message) => { // you can send 'message' emit from server side and than get the on by using 'message' keyword
console.log(message)
});
I can't emit from server because the server is written in c#.
– dummy
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Maybe this is help you.
import SocketIOClient from 'socket.io-client';
this.socket = SocketIOClient('xx.xx.xx.xx:2201', {
transports: ['websocket']
});
this.socket.on('message', (message) => { // you can send 'message' emit from server side and than get the on by using 'message' keyword
console.log(message)
});
I can't emit from server because the server is written in c#.
– dummy
yesterday
add a comment |
up vote
0
down vote
Maybe this is help you.
import SocketIOClient from 'socket.io-client';
this.socket = SocketIOClient('xx.xx.xx.xx:2201', {
transports: ['websocket']
});
this.socket.on('message', (message) => { // you can send 'message' emit from server side and than get the on by using 'message' keyword
console.log(message)
});
I can't emit from server because the server is written in c#.
– dummy
yesterday
add a comment |
up vote
0
down vote
up vote
0
down vote
Maybe this is help you.
import SocketIOClient from 'socket.io-client';
this.socket = SocketIOClient('xx.xx.xx.xx:2201', {
transports: ['websocket']
});
this.socket.on('message', (message) => { // you can send 'message' emit from server side and than get the on by using 'message' keyword
console.log(message)
});
Maybe this is help you.
import SocketIOClient from 'socket.io-client';
this.socket = SocketIOClient('xx.xx.xx.xx:2201', {
transports: ['websocket']
});
this.socket.on('message', (message) => { // you can send 'message' emit from server side and than get the on by using 'message' keyword
console.log(message)
});
answered yesterday
Yasin Ugurlu
15217
15217
I can't emit from server because the server is written in c#.
– dummy
yesterday
add a comment |
I can't emit from server because the server is written in c#.
– dummy
yesterday
I can't emit from server because the server is written in c#.
– dummy
yesterday
I can't emit from server because the server is written in c#.
– dummy
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369166%2fpush-notification-via-c-sharp-socket%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown