Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by iiiiiiiiiiiiiiiiiiiiiiii · Aug 25, 2015 at 05:22 AM · webglwwwsocket

WebGL/WebSocket has stopped while processing WWW.LoadFromCacheOrDownload

First, apologize my English. My WebGL/WebSocket has stopped while processing WWW.LoadFromCacheOrDownload on Chrome. The Server sent a packet but, client socket can not receive immediately. when WWW download has done, the client receives a number of accumulated packets.

Please, help me!

My Unity version is 5.1.2p3 and, Chrome browser version is 44.0.2403.157 and, here is my websocket.jslib code.

 var LibraryWebSockets = 
 {
     $webSocketInstances: [],
 
     SocketConnect: function(url, callee, onopen, onmessage, onclose, onerror)
     {
         var strURL = Pointer_stringify(url);
         var strCallee = Pointer_stringify(callee);
         var strOnOpen = Pointer_stringify(onopen);
         var strOnMessage = Pointer_stringify(onmessage);
         var strOnClose = Pointer_stringify(onclose);
         var strOnError = Pointer_stringify(onerror);
 
         var socket = 
         {
             socket: new WebSocket(strURL),
             buffer: new Uint8Array(0),
             error: null,
             messages: []
         }
 
         socket.socket.onopen = function(e)
         {
             SendMessage(strCallee, strOnOpen, "");
         };
 
         socket.socket.onmessage = function(e)
         {
             if (e.data instanceof Blob)
             {
                 var reader = new FileReader();
                 reader.addEventListener("loadend", function() 
                 {
                     var array = new Uint8Array(reader.result);
                     socket.messages.push(array);
                     SendMessage(strCallee, strOnMessage, "");
                 });
                 reader.readAsArrayBuffer(e.data);
             }
         };
 
         socket.socket.onclose = function(e)
         {
             if (e.code != 1000)
             {
                 if (e.reason != null && e.reason.length > 0)
                 {
                     socket.error = e.reason;
                 }
                 else
                 {
                     switch (e.code)
                     {
                         case 1001: 
                             socket.error = "Endpoint going away.";
                             break;
                         case 1002: 
                             socket.error = "Protocol error.";
                             break;
                         case 1003: 
                             socket.error = "Unsupported message.";
                             break;
                         case 1005: 
                             socket.error = "No status.";
                             break;
                         case 1006: 
                             socket.error = "Abnormal disconnection.";
                             break;
                         case 1009: 
                             socket.error = "Data frame too large.";
                             break;
                         default:
                             socket.error = "Error " + e.code;
                     }
                 }
             }
 
             SendMessage(strCallee, strOnClose, "");
         };
 
         socket.socket.onerror = function(e)
         {
             socket.error = e.data;
             SendMessage(strCallee, strOnError, "");
         }
 
         var instance = webSocketInstances.push(socket) - 1;
         return instance;
     },
 
     SocketState: function(socketInstance)
     {
         var socket = webSocketInstances[socketInstance];
         return socket.socket.readyState;
     },
 
     SocketError: function(socketInstance, ptr, bufsize)
     {
          var socket = webSocketInstances[socketInstance];
          if (socket.error == null)
              return 0;
 
         var str = socket.error.slice(0, Math.max(0, bufsize - 1));
         writeStringToMemory(str, ptr, false);
         return 1;
     },
 
     SocketSend: function(socketInstance, ptr, length)
     {
         var socket = webSocketInstances[socketInstance];
         socket.socket.send (HEAPU8.buffer.slice(ptr, ptr+length));
     },
 
     SocketRecvLength: function(socketInstance)
     {
         var socket = webSocketInstances[socketInstance];
         if (socket.messages.length == 0)
             return 0;
 
         return socket.messages[0].length;
     },
 
     SocketRecv: function(socketInstance, ptr, length)
     {
         var socket = webSocketInstances[socketInstance];
         if (socket.messages.length == 0)
             return 0;
 
         if (socket.messages[0].length > length)
             return 0;
 
         HEAPU8.set(socket.messages[0], ptr);
         socket.messages = socket.messages.slice(1);
         return 1;
     },
 
     SocketClose: function(socketInstance)
     {
         var socket = webSocketInstances[socketInstance];
         socket.socket.close();
     }
 };
 
 autoAddDeps(LibraryWebSockets, '$webSocketInstances');
 mergeInto(LibraryManager.library, LibraryWebSockets);
 

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexaust_ · Jan 06, 2016 at 10:27 AM 0
Share

Can you share the .cs file as well? Thank you!

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Simple Web Sockets for Unity WebGL - not working in background in WebGL build 2 Answers

[WEBGL] Post json - complicated structure 0 Answers

using Asset Bundles to reduce my WebGl build size 0 Answers

Unity WebGL build and PHP Post communication 0 Answers

WebGL: RuntimeError: memory access out of bounds. 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges