创建一个unity项目,然后创建一个c#的服务端项目,使用socket向服务端发送消息,如何序列化和反序列化?
1 这是前端代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Net.Sockets;
using System;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using SocketRequest;
public class GameRoot : MonoBehaviour
{
Socket client;
byte[] buffers = new byte[1024];
void Start()
{
client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
client.Connect("127.0.0.1", 6666);
StartRecv();
Send();
}
void Send()
{
Request request = new Request() {
Str="你好服务器"};