Legacy Documentation: Version 2018.2 (Go to current version)
LanguageEnglish
  • C#

NetworkServerSimple.OnData

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public void OnData(Networking.NetworkConnection conn, int receivedSize, int channelId);

Parameters

connThe connection that data was received on.
channelIdThe channel that data was received on.
receivedSizeThe amount of data received.

Description

This virtual function can be overridden to perform custom functionality when data is received for a connection.

By default this function calls HandleData() which will process the data and invoke message handlers for any messages that it finds.

using UnityEngine;
using UnityEngine.Networking;

public abstract class ExampleScript : NetworkManager { byte[] msgBuffer = new byte[1024];

public virtual void OnData(NetworkConnection conn, int channelId, int receivedSize) { conn.TransportRecieve(msgBuffer, receivedSize, channelId); } }

Did you find this page useful? Please give it a rating: