Version: 2017.1
public bool SendWriter (Networking.NetworkWriter writer, int channelId);

Parameters

writer Writer object containing data to send.
channelId QoS channel to send data on.

Returns

bool True if data successfully sent.

Description

This sends the contents of the NetworkWriter's buffer to the connected server on the specified channel.

The format of the data in the writer must be properly formatted for it to be processed as a message by the server. The functions StartMessage() and FinishMessage() can be used to properly format messages:

using UnityEngine;
using UnityEngine.Networking;

public class TestClient { public NetworkClient client;

public const int RegisterHostMsgId = 888;

public void RegisterHost(string name) { NetworkWriter writer = new NetworkWriter(); writer.StartMessage(RegisterHostMsgId); writer.Write(name); writer.FinishMessage();

client.SendWriter(writer, Channels.DefaultReliable); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961