SteamNetworkingSocket not receiving messages
See original GitHub issueDescribe the bug I’m not receiving messages, what am I doing wrong?
I’m also calling socketManager.Receive(); every frame.(it doesn’t matter if I do this or not) but I only get the OnConnecting, OnConnected, and OnDisconnected messages.
To Reproduce Steps to reproduce the behavior:
- try this code(it is in unity)
- see that “OK” gets logged for every connection*buttonpress
- see that there are no messages incoming
Calling Code this is my interface:
public class SteamSocketManagerInterface : ISocketManager
{
public void OnConnected(Connection connection, ConnectionInfo info)
{
Debug.Log("OnConnected!!");
}
public void OnConnecting(Connection connection, ConnectionInfo info)
{
connection.Accept();
Debug.Log("OnConnecting!!");
}
public void OnDisconnected(Connection connection, ConnectionInfo info)
{
Debug.Log("OnDisconnected!!");
}
public void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel)
{
Debug.Log("Got A Message!!");
}
}
this is how I try to use it:
socketManager = SteamNetworkingSockets.CreateRelaySocket<SocketManager>();
socketManager.Interface = new SteamSocketManagerInterface();
SteamNetworkingSockets.ConnectRelay<ConnectionManager>(SteamClient.SteamId);
and later on in the code, on a button press:
for (int i = 0; i < socketManager.Connected.Count; i++)
{
Result result = socketManager.Connected[i].SendMessage(bytes, sendType);
Debug.Log(result);
}
Expected behavior I expected to get a message.
Desktop (please complete the following information):
- OS: Windows10
- Unity: Unity 2019.4.0f1
Additional context I first made a class derive from SocketManager but this didn’t work and I read that it needs to be an interface to receive messages, so I tried it with this simple interface. there is also additional code so other people can join my lobby and connect with me, but I also don’t receive messages from them.
Issue Analytics
- State:
- Created 3 years ago
- Comments:19
@Scarso327 connecting through relays. Thanks so much for helping. I posted a new issue trying to explain where I’m at: https://github.com/Facepunch/Facepunch.Steamworks/issues/529
The way I have it set up in my 1v1 game is 1 host sets up the socket manager as a server and then their own connection manager to connect to it. And their opponent just has a connection manager. But I’ve been unable to send messages from connection manager to socket manager from either host or joining person.
“SocketManager’s Recieve will handle messages from ALL connections so you don’t have to loop through all connections or something like that.” thats what i also thought, but it doesnt work like you described in my code. i need to call connectionManager.Receive() to get anything, socketManager.Receive doesnt do anything(for me). Please try this code: