private static void PrintRequestHeader(System.IO.StringWriter s, Ice.InputStream str) { PrintIdentityFacetOperation(s, str); try { byte mode = str.ReadByte(); s.Write("\noperation mode = " + (int)mode + ' '); switch (mode) { case 0: { s.Write("(non-idempotent)"); break; } case 1: { s.Write("(idempotent/nonmutating)"); break; } case 2: { s.Write("(idempotent)"); break; } default: { s.Write("(unknown)"); break; } } int sz = str.ReadSize(); s.Write("\ncontext = "); while (sz-- > 0) { string key = str.ReadString(); string val = str.ReadString(); s.Write(key + '/' + val); if (sz > 0) { s.Write(", "); } } Ice.EncodingVersion v = str.SkipEncapsulation(); if (!v.Equals(Ice.Util.Encoding_1_0)) { s.Write("\nencoding = "); s.Write(Ice.Util.EncodingVersionToString(v)); } } catch (System.IO.IOException) { Debug.Assert(false); } }
public async ValueTask <OutputStream> DispatchAsync(Ice.InputStream istr, Current current) { if (current.Operation.Equals("opOneway")) { if (!current.IsOneway) { // If called two-way, return exception to caller. throw new Test.MyException(); } return(OutgoingResponseFrame.Empty(current)); } else if (current.Operation.Equals("opString")) { string s = istr.ReadString(); var responseFrame = new OutgoingResponseFrame(current); responseFrame.StartReturnValue(); responseFrame.WriteString(s); responseFrame.WriteString(s); responseFrame.EndReturnValue(); return(responseFrame); } else if (current.Operation.Equals("opException")) { if (current.Context.ContainsKey("raise")) { throw new Test.MyException(); } var ex = new Test.MyException(); return(new OutgoingResponseFrame(current, ex)); } else if (current.Operation.Equals("shutdown")) { current.Adapter.Communicator.Shutdown(); return(OutgoingResponseFrame.Empty(current)); } else if (current.Operation.Equals("ice_isA")) { string s = istr.ReadString(); var responseFrame = new OutgoingResponseFrame(current); responseFrame.StartReturnValue(); if (s.Equals("::Test::MyClass")) { responseFrame.WriteBool(true); } else { responseFrame.WriteBool(false); } responseFrame.EndReturnValue(); return(responseFrame); } else { throw new OperationNotExistException(current.Id, current.Facet, current.Operation); } }
public async ValueTask <OutputStream> DispatchAsync(Ice.InputStream istr, Current current) { if (current.Operation.Equals("opOneway")) { Debug.Assert(current.IsOneway); // TODO: replace by OutputStream.Empty return(IceInternal.Protocol.CreateEmptyResponseFrame(current)); } else if (current.Operation.Equals("opString")) { string s = istr.ReadString(); var ostr = IceInternal.Protocol.StartResponseFrame(current); ostr.WriteString(s); ostr.WriteString(s); ostr.EndEncapsulation(); return(ostr); } else if (current.Operation.Equals("opException")) { if (current.Context.ContainsKey("raise")) { throw new Test.MyException(); } var ex = new Test.MyException(); var ostr = IceInternal.Protocol.StartFailureResponseFrame(current); ostr.WriteException(ex); ostr.EndEncapsulation(); return(ostr); } else if (current.Operation.Equals("shutdown")) { current.Adapter.Communicator.Shutdown(); return(IceInternal.Protocol.CreateEmptyResponseFrame(current)); } else if (current.Operation.Equals("ice_isA")) { string s = istr.ReadString(); var ostr = IceInternal.Protocol.StartResponseFrame(current); if (s.Equals("::Test::MyClass")) { ostr.WriteBool(true); } else { ostr.WriteBool(false); } ostr.EndEncapsulation(); return(ostr); } else { throw new OperationNotExistException(current.Id, current.Facet, current.Operation); } }
internal WSEndpoint(TransportInstance instance, Endpoint del, Ice.InputStream s) { _instance = instance; _delegate = del; _resource = s.ReadString(); }
internal WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s) { _instance = instance; _delegate = del; _resource = s.ReadString(); }
private static void printIdentityFacetOperation(System.IO.StringWriter s, Ice.InputStream str) { try { Ice.ToStringMode toStringMode = str.Communicator()?.ToStringMode ?? Ice.ToStringMode.Unicode; Ice.Identity identity = new Ice.Identity(); identity.ice_readMembers(str); s.Write("\nidentity = " + identity.ToString(toStringMode)); string[] facet = str.ReadStringSeq(); s.Write("\nfacet = "); if (facet.Length > 0) { s.Write(IceUtilInternal.StringUtil.escapeString(facet[0], "", toStringMode)); } string operation = str.ReadString(); s.Write("\noperation = " + operation); } catch (System.IO.IOException) { Debug.Assert(false); } }
public IPEndpoint(TransportInstance instance, Ice.InputStream s) { Instance = instance; Host = s.ReadString(); Port = s.ReadInt(); SourceAddr = null; ConnectionId_ = ""; }
public IPEndpointI(ProtocolInstance instance, Ice.InputStream s) { instance_ = instance; host_ = s.ReadString(); port_ = s.ReadInt(); sourceAddr_ = null; connectionId_ = ""; _hashInitialized = false; }
public IPEndpoint(ProtocolInstance instance, Ice.InputStream s) { Instance = instance; Host = s.ReadString(); Port = s.ReadInt(); SourceAddr = null; ConnectionId_ = ""; _hashInitialized = false; }
public async ValueTask <OutgoingResponseFrame> DispatchAsync(Ice.InputStream istr, Current current) { if (current.Operation.Equals("opOneway")) { if (!current.IsOneway) { // If called two-way, return exception to caller. throw new Test.MyException(); } return(OutgoingResponseFrame.WithVoidReturnValue(current)); } else if (current.Operation.Equals("opString")) { string s = istr.ReadString(); var responseFrame = OutgoingResponseFrame.WithReturnValue(current, format: null, (s, s), (OutputStream ostr, (string ReturnValue, string s2)value) => { ostr.WriteString(value.ReturnValue); ostr.WriteString(value.s2); });
public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // var id = new Ice.Identity(); id.ice_readMembers(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.ReadStringSeq(); string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = _is.ReadString(); byte mode = _is.ReadByte(); Dictionary <string, string> context = new Dictionary <string, string>(); int sz = _is.ReadSize(); while (sz-- > 0) { string first = _is.ReadString(); string second = _is.ReadString(); context[first] = second; } _current = new Ice.Current(_adapter, id, facet, operation, (Ice.OperationMode)mode, context, _requestId, _connection); Ice.Instrumentation.CommunicatorObserver?obsv = _communicator.Observer; if (obsv != null) { // Read the encapsulation size. int size = _is.ReadInt(); _is.pos(_is.pos() - 4); _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size); if (_observer != null) { _observer.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (servantManager != null) { _servant = servantManager.findServant(_current.Id, _current.Facet); if (_servant == null) { _locator = servantManager.findServantLocator(_current.Id.category); if (_locator == null && _current.Id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if (_locator != null) { Debug.Assert(_locator != null); try { _servant = _locator.locate(_current, out _cookie); } catch (Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); return; } } } } if (_servant == null) { try { if (servantManager != null && servantManager.hasServant(_current.Id)) { throw new Ice.FacetNotExistException(_current.Id, _current.Facet, _current.Operation); } else { throw new Ice.ObjectNotExistException(_current.Id, _current.Facet, _current.Operation); } } catch (Exception ex) { skipReadParams(); // Required for batch requests handleException(ex, false); return; } } try { Task <Ice.OutputStream>?task = _servant(this, _current); if (task == null) { completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); completed(null, true); // true = asynchronous } catch (Exception ex) { completed(ex, true); // true = asynchronous } }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, scheduler: TaskScheduler.Current); } } } catch (Exception ex) { completed(ex, false); } }
private static void PrintReply(System.IO.StringWriter s, Ice.InputStream str) { int requestId = str.ReadInt(); s.Write("\nrequest id = " + requestId); byte replyStatus = str.ReadByte(); s.Write("\nreply status = " + (int)replyStatus + ' '); switch (replyStatus) { case ReplyStatus.replyOK: { s.Write("(ok)"); break; } case ReplyStatus.replyUserException: { s.Write("(user exception)"); break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { switch (replyStatus) { case ReplyStatus.replyObjectNotExist: { s.Write("(object not exist)"); break; } case ReplyStatus.replyFacetNotExist: { s.Write("(facet not exist)"); break; } case ReplyStatus.replyOperationNotExist: { s.Write("(operation not exist)"); break; } default: { Debug.Assert(false); break; } } PrintIdentityFacetOperation(s, str); break; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { switch (replyStatus) { case ReplyStatus.replyUnknownException: { s.Write("(unknown exception)"); break; } case ReplyStatus.replyUnknownLocalException: { s.Write("(unknown local exception)"); break; } case ReplyStatus.replyUnknownUserException: { s.Write("(unknown user exception)"); break; } default: { Debug.Assert(false); break; } } string unknown = str.ReadString(); s.Write("\nunknown = " + unknown); break; } default: { s.Write("(unknown)"); break; } } if (replyStatus == ReplyStatus.replyOK || replyStatus == ReplyStatus.replyUserException) { Ice.EncodingVersion v = str.SkipEncapsulation(); if (!v.Equals(Ice.Util.Encoding_1_0)) { s.Write("\nencoding = "); s.Write(Ice.Util.EncodingVersionToString(v)); } } }
public void Invoke(Ice.InputStream stream) { _is = stream; int start = _is.Pos; // // Read the current. // var id = new Ice.Identity(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.ReadStringArray(); string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = _is.ReadString(); byte mode = _is.ReadByte(); var context = new Dictionary <string, string>(); int sz = _is.ReadSize(); while (sz-- > 0) { string first = _is.ReadString(); string second = _is.ReadString(); context[first] = second; } _current = new Ice.Current(_adapter, id, facet, operation, (Ice.OperationMode)mode, context, _requestId, _connection); Ice.Instrumentation.ICommunicatorObserver?obsv = _communicator.Observer; if (obsv != null) { // Read the encapsulation size. int size = _is.ReadInt(); _is.Pos -= 4; _observer = obsv.GetDispatchObserver(_current, _is.Pos - start + size); if (_observer != null) { _observer.Attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // _servant = _adapter.Find(_current.Id, _current.Facet); if (_servant == null) { try { throw new Ice.ObjectNotExistException(_current.Id, _current.Facet, _current.Operation); } catch (Exception ex) { SkipReadParams(); // Required for batch requests HandleException(ex, false); return; } } try { Task <Ice.OutputStream?>?task = _servant.Dispatch(this, _current); if (task == null) { Completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response Completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); Completed(null, true); // true = asynchronous } catch (Exception ex) { Completed(ex, true); // true = asynchronous } }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, scheduler: TaskScheduler.Current); } } } catch (Exception ex) { Completed(ex, false); } }