From the course: Unity: AR Visualization 03 Complex Interactivity

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a message handler

Creating a message handler - Unity Tutorial

From the course: Unity: AR Visualization 03 Complex Interactivity

Start my 1-month free trial

Creating a message handler

- [Instructor] Now that we've got our connection all set up messages are going to be flying fast and furious. Let's learn how to deal with them. Double click on the network manager, now the best way to deal with messages is to aggregate them all into a list and deal with them once per update loop. So I'm going to need a list of messages. Let's go create that under username. I'm going to create a private list I'll type message. We're going to call this messages. I'm going to initialize it. Great. Now I'm going to go down to my message handler and I'm going to add it to the stack. So messages.Add and grab my message. Excellent. Now I'm going to add a method to process my messages. Just underneath disconnect I'm going to add a private void I'm going to call this process messages. All right. So what I'm going to do here is iterate through all the messages I receive and then when I'm done I'm going to clear. So I'm…

Contents