Hi there,
i’m trying to develop a network application using networkcomms library. I implemented a few IncommingPackageHandler at the server side that work, but i’m stucking on the following server/client code:
Server:
public override void SetupConnection(){
logger.Debug ("Setting up Listeners for Worker {0}", connection);
connection.AppendIncomingPacketHandler<ShapeFilePartsRequest>("ShapeFilePartsRequest", ShapeFilePartsRequest);
connection.AppendIncomingPacketHandler<ShapeFilePartVectorsRequest>("ShapeFilePartVectorsRequest", ShapePartVectorsRequest);
}
public void ShapeFilePartsRequest(PacketHeader header, Connection connection, ShapeFilePartsRequest request){
logger.Info("Client {0} requested information about parts in {1}",connection, request.Filename);
IFeatureSet fs = FeatureSet.Open(request.Filename);
ShapeFilePartsResponse resp = new ShapeFilePartsResponse ();
foreach (ShapeRange shape in fs.ShapeIndices)
{
resp.shapes.Add (new ShapeInfo (shape.FeatureType.ToString(), shape.StartIndex));
}
logger.Debug("Sending client {0} information about {1} shapes in {2}", connection, resp.shapes.Count, request.Filename);
connection.SendObject("ShapeFilePartsResponse", resp);
fs.Close ();
}
Client:
public List<ShapeInfo> requestShapeInfo(string filename){
ShapeFilePartsRequest shapesRequest = new ShapeFilePartsRequest();
shapesRequest.Filename = filename;
ShapeFilePartsResponse partsResponse = connection.SendReceiveObject<ShapeFilePartsRequest,ShapeFilePartsResponse>("ShapeFilePartsRequest", "ShapeFilePartsResponse" , 5000, shapesRequest);
Debug.Log ("received partsResponse with " + partsResponse.shapes.Count + " shape infos");
return partsResponse.shapes;
}
The Server gets the request, does his things, and according to the logs, it sends a package of type “”ShapeFilePartsResponse”” back to the client, but the client doesn’t seem to receive his message, it gets a timeout. The other PackageHandler i wrote do have similar code and are working perfect.
-
This topic was modified 9 years, 11 months ago by .