Sign In Register

How can we help you today?

Start a new topic

GetRTSession().SendData cant work

 I send a packet with opcode 0 to the server but it is not sent!

I initialize data variable, add GameSparksRTUnity,..

and I have no error. I read game Tank example and implemented my game like it:

in unity

public void send(){

GameSparksManager.get_instance().GetRTSession().SendData((0,GameSparksRT.DeliveryIntent.RELIABLE, data);// send the data

}

private void OnPacketReceived(RTPacket _packet)
  {
  print(_packet.OpCode);
  switch (_packet.OpCode)
  {
  case 0:
  GameManager.get_instance().receive_opponentNochesInfo(_packet);
  break;

  }
}



in RT script cloud code:

RTSession.onPlayerConnect(function(player){

  if(totalPlayers === 0){

  RTSession.newRequest().createMatchDetailsRequest()
  .setMatchId(RTSession.getSessionId())
  .setPlayerId(player.getPlayerId())
  .setRealtimeEnabled(true)
  .send(function(response){
  totalPlayers = response.opponents.length + 1; // we add one to this because the opponents list doesn't include us
  });
  }

  // first we check to see if the player has already joined the match
  if(!contains(player.getPeerId(), playersJoined)){
  playersJoined.push(player.getPeerId()); // and add them if not
  }
  // next we check to see the max (or min) number of players has joined that match
  if(playersJoined.length === totalPlayers){
  RTSession.newPacket().setOpCode(100).setReliable(true).setTargetPeers().send(); // send an empty pack back to all players
  RTSession.newPacket().setOpCode(200).setReliable(false).setTargetPeers().send(); // send an empty pack back to all players
  RTSession.newPacket().setOpCode(300).setReliable(true).setTargetPeers().send(); // send an empty pack back to all players
  RTSession.newPacket().setOpCode(400).setReliable(true).setTargetPeers().send(); // send an empty pack back to all players

  }
});

RTSession.onPacket(0, function(packet){
RTSession.newPacket().setData(packet.getData()).setOpCode(0).setReliable(true).setTargetPeers().send();
});



I don't see any print log in unity sent from OnPacketReceived!

Note a match has been found and I see a correct log and packet data onPlayerConnect(100,200,300,400)

"Match found"

"Starting session"

"GSM RT session Connected..."

100

200

300

400

I send data after RT session Connected.


1 person has this question
1 Comment

Hi Mahd,


This is being handled in the ticketing system.


Thanks,

Liam

Login to post a comment