- Home /
Question by
klkuns12811 · Feb 17, 2017 at 09:15 AM ·
unity 5networkingwindows store app
Windows Store Platform Build Issues with Networking
I have a program that connects, sends and receives a message over a network, and it runs fine when built on other platforms or when I just hit the play button to demo it. As soon as I build it for windows store, I get the error shown below. The dialog above the error is from when I demoed it with the play button. It doesn't give me any details as to what is wrong so I'm a little stuck here. I included my code at the bottom. Any help would be appreciated soooooo much.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class Transport : NetworkBehaviour {
int myReliableChannelId;
int socketId;
int socketPort = 8888;
int connectionId;
// Use this for initialization
void Start () {
NetworkTransport.Init();
ConnectionConfig config = new ConnectionConfig();
myReliableChannelId = config.AddChannel(QosType.Reliable);
int maxConnections = 10;
HostTopology topology = new HostTopology(config, maxConnections);
socketId = NetworkTransport.AddHost(topology, socketPort);
Debug.Log("Socket Open. SocketId is: " + socketId);
}
// Update is called once per frame
void Update () {
int recHostId;
int recConnectionId;
int recChannelId;
byte[] recBuffer = new byte[1024];
int bufferSize = 1024;
int dataSize;
byte error;
NetworkEventType recNetworkEvent = NetworkTransport.Receive(out recHostId, out recConnectionId, out recChannelId, recBuffer, bufferSize, out dataSize, out error);
switch (recNetworkEvent)
{
case NetworkEventType.Nothing:
break;
case NetworkEventType.ConnectEvent:
Debug.Log("incoming connection event received");
break;
case NetworkEventType.DataEvent:
Stream stream = new MemoryStream(recBuffer);
BinaryFormatter formatter = new BinaryFormatter();
string message = formatter.Deserialize(stream) as string;
Debug.Log("incoming message event received: " + message);
break;
}
}
public void Connect()
{
byte error;
connectionId = NetworkTransport.Connect(socketId, "127.0.0.1", socketPort, 0, out error);
Debug.Log("Connected to Server. ConnectionId: " + connectionId);
}
public void SendSocketMessage()
{
byte error;
byte[] buffer = new byte[1024];
Stream stream = new MemoryStream(buffer);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, "HelloServer");
int buffersize = 1024;
NetworkTransport.Send(socketId, connectionId, myReliableChannelId, buffer, buffersize, out error);
}
}
capture.png
(29.5 kB)
Comment
Your answer
