c \ # 의 SocketIoClient DotNet 라 이브 러 리 는 nodejs 의 socket. io 와 연결 할 수 있 습 니 다.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Quobject.SocketIoClientDotNet.Client;
namespace socket
{
class Program
{
static void Main(string[] args)
{
var socket = IO.Socket("http://114.55.104.1:8090/");//
socket.On(Socket.EVENT_CONNECT, () => //
{
Console.WriteLine(" ");
socket.Emit("hi","ccdcd"); // , : , ,
socket.On("cd", (data) => //
{
var b=(JObject)data; //
Console.WriteLine(b['name']);
Console.WriteLine(data);
socket.Disconnect(); //
});
});
socket.Connect(); //
socket.On(Socket.EVENT_DISCONNECT,()=> {
this.m_robot.OutLogMsg(" ");
conn_net = false;
socket.Close();
}); //socket.close(); disconnect reconnet
Console.ReadKey();
}
}
}
socket 에서 제 이 슨 으로 데 이 터 를 전달 합 니 다.
JObject a=new JObject();
a.Add("name","liushuai");
JArray arr = new JArray();
arr.Add(new JValue(1));
arr.Add(new JValue(2));
a.Add('time',arr);
socket.Emit("data",a);
참고 주소:https://stackoverflow.com/questions/39135966/unable-to-use-socketioclientdotnet-with-external-server
https://stackoverflow.com/questions/32190867/socket-io-in-c-socketioclientdotnet-and-socketio4net-failed
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C#Task를 사용하여 비동기식 작업을 수행하는 방법라인이 완성된 후에 이 라인을 다시 시작할 수 없습니다.반대로 조인(Join)만 결합할 수 있습니다 (프로세스가 현재 라인을 막습니다). 임무는 조합할 수 있는 것이다. 연장을 사용하여 그것들을 한데 연결시키는 것이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.