I am trying to send a quite large object (approximately 229 KB) from unity to smartfox, but i can't get it to work. I want to send information about a unit to smartfox and then store this information on a mySQL database. The plan is that i later can access this information during runtime and create a new unit based on that information. At the moment i am adding all the necessary information to a hashtable and then serializing it and sending it to smartfox as a byte array, but it doesn't work. Any ideas on how i can do this?
Code in Unity
Code: Select all
MemoryStream memoryStream = new System.IO.MemoryStream();
BinaryFormatter binaryFormatter = new BinaryFormatter();
SFSObject data = new SFSObject();
Hashtable info = new Hashtable();
//Adds information about the unit.
info.Add("unitSize", 12.52f);
info.Add("skills", 1);
info.Add("description", "This is a unit");
Mesh objMesh = gameObject.GetComponent<MeshFilter>().mesh;
//Adds the information necessary for recreating the mesh.
info.Add("vertices", VectorToFloatArray(objMesh.vertices));
info.Add("uv", VectorToFloatArray(objMesh.uv));
info.Add("normals", VectorToFloatArray(objMesh.normals));
info.Add("triangles", objMesh.triangles);
info.Add("texture", unit.EncodeToPNG());
binaryFormatter.Serialize(memoryStream, info);
Sfs2X.Util.ByteArray byteArray = new Sfs2X.Util.ByteArray(memoryStream.ToArray());
data.PutByteArray("unit", byteArray);
smartfox.Send(new ExtensionRequest("unitToSQL", data, meshLogin.smartfox.LastJoinedRoom, false));
Error in Smartfox Console
Code: Select all
12:37:31,547 INFO [com.smartfoxserver.v2.controllers.SystemController-1] api.SFSApi - Login in, { Zone: test }, ( User Name: Birch, Id: 2, Priv: 0, Sess: 192.168.1.3 )
12:37:31,586 INFO [com.smartfoxserver.v2.controllers.SystemController-1] api.SFSApi - Room created: [ Room: A Room, Id: 4, Group: default, isGame: true ]
12:37:40,139 ERROR [1519652738@qtp-878483699-6] mortbay.log - /BlueBox/BlueBox.do
java.lang.IllegalStateException: Form too large304942>200000
at org.mortbay.jetty.Request.extractParameters(Request.java:1561)
at org.mortbay.jetty.Request.getParameter(Request.java:859)
at com.smartfoxserver.v2.bluebox.SessionFilter.doFilter(SessionFilter.java:108)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)