| 53 | } |
| 54 | |
| 55 | void FlashMainStream::messageHandler(const string& name,AMFReader& message,FlashWriter& writer) { |
| 56 | if(name=="connect") { |
| 57 | message.stopReferencing(); |
| 58 | |
| 59 | |
| 60 | ParameterWriter parameterWriter(peer.properties()); |
| 61 | |
| 62 | if(message.read(AMFReader::OBJECT,parameterWriter)) { |
| 63 | |
| 64 | if (peer.properties().getString("tcUrl",_buffer)) { |
| 65 | string serverAddress; |
| 66 | Util::UnpackUrl(_buffer, serverAddress,(string&)peer.path,(string&)peer.query); |
| 67 | peer.setServerAddress(serverAddress); |
| 68 | Util::UnpackQuery(peer.query, peer.properties()); |
| 69 | } |
| 70 | |
| 71 | if (peer.properties().getNumber<UInt32,3>("objectEncoding")==0) { |
| 72 | writer.amf0 = true; |
| 73 | WARN("Client ",peer.protocol," not compatible with AMF3, few complex object can be not supported"); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | message.startReferencing(); |
| 78 | |
| 79 | |
| 80 | // Check if the client is authorized |
| 81 | AMFWriter& response = writer.writeAMFSuccess("NetConnection.Connect.Success","Connection succeeded",true); |
| 82 | response.amf0 = true; |
| 83 | response.writeNumberProperty("objectEncoding",writer.amf0 ? 0.0 : 3.0); |
| 84 | response.amf0 = writer.amf0; |
| 85 | Exception ex; |
| 86 | peer.onConnection(ex, writer,message,response); |
| 87 | if (ex) { |
| 88 | switch(ex.code()) { |
| 89 | case Exception::SOFTWARE: |
| 90 | writer.writeAMFError("NetConnection.Connect.Rejected",ex.error()); |
| 91 | break; |
| 92 | case Exception::APPLICATION: |
| 93 | writer.writeAMFError("NetConnection.Connect.InvalidApp",ex.error()); |
| 94 | break; |
| 95 | default: |
| 96 | writer.writeAMFError("NetConnection.Connect.Failed",ex.error()); |
| 97 | } |
| 98 | writer.writeInvocation("close"); |
| 99 | writer.close(); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | response.endObject(); |
| 104 | |
| 105 | } else if(name == "setPeerInfo") { |
| 106 | |
| 107 | peer.localAddresses.clear(); |
| 108 | while(message.available()) { |
| 109 | SocketAddress address; |
| 110 | Exception ex; |
| 111 | _buffer.clear(); |
| 112 | if (!message.readString(_buffer) || _buffer.empty()) |
nothing calls this directly
no test coverage detected