Unity messaging problem - cant send from client to server

Hi guys! I really cant handle a problem with sending messages. Every time when I try to send message i get “NullReferenceException: Object reference not set to an instance of an object
Message+MasterClient.RegisterHost (System.String name) (at Assets/Message.cs:27)
Message.Update () (at Assets/Message.cs:34)”. Here is my code, please help if possible

Client:
using UnityEngine;
using UnityEngine.Networking;

public class Message : NetworkBehaviour
{
	class RegisterHostMessage : MessageBase
	{
		public string gameName;
		public string comment;
		public bool passwordProtected;

	}

	class MasterClient 
	{
		public NetworkClient client;

		public const short RegisterHotsMsgId = 888;

		public void RegisterHost(string name)
		{
			RegisterHostMessage msg = new RegisterHostMessage();
			msg.gameName = name;
			msg.comment = "test";
			msg.passwordProtected = false;

			client.Send(RegisterHotsMsgId, msg);
		}
	}

	void Update()
	{
			MasterClient mast = new MasterClient ();
			mast.RegisterHost ("works");
	}
}

Server: using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class ServerStart : NetworkBehaviour {

void Start()
{
	Debug.Log ("Registering server callbacks");

}
void Update()
{
	NetworkServer.RegisterHandler(888, OnMessage);
}
void OnMessage(NetworkMessage netMsg)
{
	Debug.Log ("Client get");
}

}

Sorry, there’s a lot of problems here, you really should learn the programming basics before you try something like this.

In case you’re wondering what’s wrong:

  • Why is this not instantiated (what causes your error): public NetworkClient client;
  • Why are you doing this in the Update() instead of Start(): MasterClient mast = new MasterClient ();
  • Again, why are you doing this every frame: NetworkServer.RegisterHandler(888, OnMessage);