public void sendResponse(int requestId, Ice.OutputStream os, byte status, bool amd) { OutgoingAsyncBase outAsync; lock (this) { Debug.Assert(_response); if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); } // Adopt the OutputStream's buffer. Ice.InputStream iss = new Ice.InputStream(os.instance(), os.getEncoding(), os.getBuffer(), true); iss.pos(Protocol.replyHdr.Length + 4); if (_traceLevels.protocol >= 1) { TraceUtil.traceRecv(iss, _logger, _traceLevels); } if (_asyncRequests.TryGetValue(requestId, out outAsync)) { outAsync.getIs().swap(iss); if (!outAsync.response()) { outAsync = null; } _asyncRequests.Remove(requestId); } } if (outAsync != null) { if (amd) { outAsync.invokeResponseAsync(); } else { outAsync.invokeResponse(); } } _adapter.decDirectCount(); }
private void invokeAll(Ice.OutputStream os, int requestId, int batchRequestNum) { if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); if (requestId > 0) { fillInValue(os, Protocol.headerSize, requestId); } else if (batchRequestNum > 0) { fillInValue(os, Protocol.headerSize, batchRequestNum); } TraceUtil.traceSend(os, _logger, _traceLevels); } Ice.InputStream iss = new Ice.InputStream(os.instance(), os.getEncoding(), os.getBuffer(), false); if (batchRequestNum > 0) { iss.pos(Protocol.requestBatchHdr.Length); } else { iss.pos(Protocol.requestHdr.Length); } int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1; ServantManager servantManager = _adapter.getServantManager(); try { while (invokeNum > 0) { // // Increase the direct count for the dispatch. We increase it again here for // each dispatch. It's important for the direct count to be > 0 until the last // collocated request response is sent to make sure the thread pool isn't // destroyed before. // try { _adapter.incDirectCount(); } catch (Ice.ObjectAdapterDeactivatedException ex) { handleException(requestId, ex, false); break; } Incoming inS = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0, requestId); inS.invoke(servantManager, iss); --invokeNum; } } catch (Ice.LocalException ex) { invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception } _adapter.decDirectCount(); }
internal static void trace(string heading, Ice.OutputStream str, Ice.Logger logger, TraceLevels tl) { if (tl.protocol >= 1) { int p = str.pos(); Ice.InputStream iss = new Ice.InputStream(str.instance(), str.getEncoding(), str.getBuffer(), false); iss.pos(0); using (System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture)) { s.Write(heading); printMessage(s, iss); logger.trace(tl.protocolCat, s.ToString()); } str.pos(p); } }
internal static void traceSend(Ice.OutputStream str, Ice.Logger logger, TraceLevels tl) { if (tl.protocol >= 1) { int p = str.pos(); Ice.InputStream iss = new Ice.InputStream(str.instance(), str.getEncoding(), str.getBuffer(), false); iss.pos(0); using (System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture)) { byte type = printMessage(s, iss); logger.trace(tl.protocolCat, "sending " + getMessageTypeAsString(type) + " " + s.ToString()); } str.pos(p); } }
public EndpointI create(string str, bool oaEndpoint) { string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n"); if (arr == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quote"; throw e; } if (arr.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } List <string> v = new List <string>(arr); string protocol = v[0]; v.RemoveAt(0); if (protocol.Equals("default")) { protocol = _instance.defaultsAndOverrides().defaultProtocol; } EndpointFactory factory = null; lock (this) { for (int i = 0; i < _factories.Count; i++) { EndpointFactory f = _factories[i]; if (f.protocol().Equals(protocol)) { factory = f; } } } if (factory != null) { EndpointI e = factory.create(v, oaEndpoint); if (v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } return(e); // Code below left in place for debugging. /* * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); * BasicStream bs = new BasicStream(_instance, true); * e.streamWrite(bs); * Buffer buf = bs.getBuffer(); * buf.b.position(0); * short type = bs.readShort(); * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); * System.Console.Error.WriteLine("Normal: " + e); * System.Console.Error.WriteLine("Opaque: " + ue); * return e; */ } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if (protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(v); if (v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } factory = get(ue.type()); if (factory != null) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // Ice.OutputStream os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); os.writeShort(ue.type()); ue.streamWrite(os); Ice.InputStream iss = new Ice.InputStream(_instance, Ice.Util.currentProtocolEncoding, os.getBuffer(), true); iss.pos(0); iss.readShort(); // type iss.startEncapsulation(); EndpointI e = factory.read(iss); iss.endEncapsulation(); return(e); } return(ue); // Endpoint is opaque, but we don't have a factory for its type. } return(null); }
public EndpointI create(string str, bool oaEndpoint) { string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n"); if(arr == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quote"; throw e; } if(arr.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } List<string> v = new List<string>(arr); string protocol = v[0]; v.RemoveAt(0); if(protocol.Equals("default")) { protocol = instance_.defaultsAndOverrides().defaultProtocol; } EndpointFactory factory = null; lock(this) { for(int i = 0; i < _factories.Count; i++) { EndpointFactory f = _factories[i]; if(f.protocol().Equals(protocol)) { factory = f; } } } if(factory != null) { EndpointI e = factory.create(v, oaEndpoint); if(v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } return e; // Code below left in place for debugging. /* EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); BasicStream bs = new BasicStream(instance_, true); e.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); short type = bs.readShort(); EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); System.Console.Error.WriteLine("Normal: " + e); System.Console.Error.WriteLine("Opaque: " + ue); return e; */ } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if(protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(v); if(v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } factory = get(ue.type()); if(factory != null) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // Ice.OutputStream os = new Ice.OutputStream(instance_, Ice.Util.currentProtocolEncoding); os.writeShort(ue.type()); ue.streamWrite(os); Ice.InputStream iss = new Ice.InputStream(instance_, Ice.Util.currentProtocolEncoding, os.getBuffer(), true); iss.pos(0); iss.readShort(); // type iss.startEncapsulation(); EndpointI e = factory.read(iss); iss.endEncapsulation(); return e; } return ue; // Endpoint is opaque, but we don't have a factory for its type. } return null; }