Exemple #1
0
    private void ReceiveWrongMessage(Message.BaseMessage wrongMessage)
    {
        Debug.Log("Remote turn wrong message");

        if (wrongMessage.Type == Message.OpponentDisconnected.TypeId)
        {
            game.OpponentDisconnected();
        }
        else
        {
            game.ReceiveUnknownMessage(wrongMessage, "Position");
        }
    }
    private bool Send(NetworkStream ns, Message.BaseMessage message)
    {
        Console.WriteLine("SendMessage: " + message.ToString());
        IFormatter formatter = new BinaryFormatter();

        try
        {
            formatter.Serialize(ns, message);
            return(true);
        }
        catch (SerializationException sendError)
        {
            Console.WriteLine("SendMessage {0} error: {1}/{2}", message, sendError.Message, sendError.InnerException);
            return(false);
        }
    }
Exemple #3
0
 public void ReceiveUnknownMessage(Message.BaseMessage wrongMessage, string awaitedMessage)
 {
     Debug.LogFormat("Received wrong message {0} [awaiting {1}]", wrongMessage, awaitedMessage);
 }