Author Topic: Exception has been thrown by the target of an invocation.  (Read 1430 times)

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Exception has been thrown by the target of an invocation.
« on: February 21, 2014, 01:43:51 PM »
Hey,

i got a error when i try make smth. in the Notifications.

  1.    
  2.    /// <summary>
  3.    /// We leave the current room
  4.    /// </summary>
  5.    void OnNetworkJoinChannel(bool success, string message)
  6.    {
  7.        if(success==false)
  8.            TNManager.JoinRandomChannel("Level", false, 8, "");
  9.        Debug.Log("OnNetworkJoinChannel: " + message);
  10.  
  11.        chatScript.addGameChatMessage(playerName + " joined the game");
  12.    }

And in my FPSChat.cs
  1.     //Add game messages etc
  2.     public void addGameChatMessage(string str){
  3.         Debug.Log("AddgameChatMessage");
  4.             ApplyGlobalChatText("", str);
  5.             if(TNManager.isInChannel){
  6.                     tno.Send("ApplyGlobalChatText", Target.Others, "", str);   
  7.             }  
  8.     }

And an another question, how can i send an Audio RFC?
I got an Error, that TN can't send's AudioClips.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Exception has been thrown by the target of an invocation.
« Reply #1 on: February 21, 2014, 05:00:51 PM »
And which line is the error on? I'm guessing you have a null ref exception there. Add some null checks for your code.

In your OnNetworkJoinChannel you seem to be calling JoinRandomChannel, and then proceed to use chatScript. Does chatScript even exist? I'm guessing you want to wait until you get "success == true" before doing anything. JoinChannel is a delayed call. You shouldn't do anything after calling it.

To send audio data, send its bytes. You can't send the clip.