本文整理汇总了C#中IceInternal.BasicStream.pos方法的典型用法代码示例。如果您正苦于以下问题:C# BasicStream.pos方法的具体用法?C# BasicStream.pos怎么用?C# BasicStream.pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IceInternal.BasicStream
的用法示例。
在下文中一共展示了BasicStream.pos方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: dumpStream
public static void dumpStream(BasicStream stream)
{
int pos = stream.pos();
stream.pos(0);
byte[] data = new byte[stream.size()];
stream.readBlob(data);
dumpOctets(data);
stream.pos(pos);
}
示例2: traceRecv
internal static void traceRecv(BasicStream str, Ice.Logger logger, TraceLevels tl)
{
if(tl.protocol >= 1)
{
int p = str.pos();
str.pos(0);
using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
{
byte type = printMessage(s, str);
logger.trace(tl.protocolCat, "received " + getMessageTypeAsString(type) + " " + s.ToString());
}
str.pos(p);
}
}
示例3: trace
internal static void trace(string heading, BasicStream str, Ice.Logger logger, TraceLevels tl)
{
if(tl.protocol >= 1)
{
int p = str.pos();
str.pos(0);
using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
{
s.Write(heading);
printMessage(s, str);
logger.trace(tl.protocolCat, s.ToString());
}
str.pos(p);
}
}
示例4: StreamWrapper
//
// Writeable stream constructor
//
public StreamWrapper(BasicStream s)
{
type_ = StreamType.Write;
s_ = s;
spos_ = s.pos();
bytes_ = new byte[254];
pos_ = 0;
length_ = 0;
}
示例5: invoke
public void invoke(ServantManager servantManager, BasicStream stream)
{
_is = stream;
int start = _is.pos();
//
// Read the current.
//
current_.id.read__(_is);
//
// For compatibility with the old FacetPath.
//
string[] facetPath = _is.readStringSeq();
if(facetPath.Length > 0)
{
if(facetPath.Length > 1)
{
throw new Ice.MarshalException();
}
current_.facet = facetPath[0];
}
else
{
current_.facet = "";
}
current_.operation = _is.readString();
current_.mode = (Ice.OperationMode)(int)_is.readByte();
current_.ctx = new Dictionary<string, string>();
int sz = _is.readSize();
while(sz-- > 0)
{
string first = _is.readString();
string second = _is.readString();
current_.ctx[first] = second;
}
Ice.Instrumentation.CommunicatorObserver obsv = instance_.initializationData().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)
{
try
{
servant_ = locator_.locate(current_, out cookie_);
}
catch(Ice.UserException ex)
{
Ice.EncodingVersion encoding = _is.skipEncaps(); // Required for batch requests.
if(observer_ != null)
{
observer_.userException();
}
if(response_)
{
os_.writeByte(ReplyStatus.replyUserException);
os_.startWriteEncaps(encoding, Ice.FormatType.DefaultFormat);
os_.writeUserException(ex);
os_.endWriteEncaps();
if(observer_ != null)
{
observer_.reply(os_.size() - Protocol.headerSize - 4);
}
responseHandler_.sendResponse(current_.requestId, os_, compress_, false);
}
else
{
responseHandler_.sendNoResponse();
//.........这里部分代码省略.........
示例6: sendResponse
public void sendResponse(int requestId, BasicStream os, byte status, bool amd)
{
Ice.AsyncCallback cb = null;
OutgoingAsyncBase outAsync;
lock(this)
{
Debug.Assert(_response);
os.pos(Protocol.replyHdr.Length + 4);
if(_traceLevels.protocol >= 1)
{
fillInValue(os, 10, os.size());
TraceUtil.traceRecv(os, _logger, _traceLevels);
}
if(_asyncRequests.TryGetValue(requestId, out outAsync))
{
_asyncRequests.Remove(requestId);
outAsync.getIs().swap(os);
cb = outAsync.completed();
}
}
if(cb != null)
{
if(amd)
{
outAsync.invokeCompletedAsync(cb);
}
else
{
outAsync.invokeCompleted(cb);
}
}
_adapter.decDirectCount();
}
示例7: invokeAll
private void invokeAll(BasicStream os, int requestId, int batchRequestNum)
{
if(batchRequestNum > 0)
{
os.pos(Protocol.requestBatchHdr.Length);
}
else
{
os.pos(Protocol.requestHdr.Length);
}
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);
}
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 @in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0,
requestId);
@in.invoke(servantManager, os);
--invokeNum;
}
}
catch(Ice.LocalException ex)
{
invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception
}
_adapter.decDirectCount();
}
示例8: invokeAll
private void invokeAll(BasicStream os, int requestId, int invokeNum, bool batch)
{
if(batch)
{
os.pos(Protocol.requestBatchHdr.Length);
}
else
{
os.pos(Protocol.requestHdr.Length);
}
if(_traceLevels.protocol >= 1)
{
fillInValue(os, 10, os.size());
if(requestId > 0)
{
fillInValue(os, Protocol.headerSize, requestId);
}
else if(batch)
{
fillInValue(os, Protocol.headerSize, invokeNum);
}
TraceUtil.traceSend(os, _logger, _traceLevels);
}
ServantManager servantManager = _adapter.getServantManager();
try
{
while(invokeNum > 0)
{
try
{
_adapter.incDirectCount();
}
catch(Ice.ObjectAdapterDeactivatedException ex)
{
handleException(requestId, ex, false);
return;
}
Incoming @in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0,
requestId);
@in.invoke(servantManager, os);
--invokeNum;
}
}
catch(Ice.LocalException ex)
{
invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception
}
}
示例9: compress
public bool compress(ref BasicStream cstream, int headerSize, int compressionLevel)
{
#if MANAGED || COMPACT
cstream = this;
return false;
#else
if(!_bzlibInstalled)
{
cstream = this;
return false;
}
//
// Compress the message body, but not the header.
//
int uncompressedLen = size() - headerSize;
byte[] uncompressed = _buf.b.rawBytes(headerSize, uncompressedLen);
int compressedLen = (int)(uncompressedLen * 1.01 + 600);
byte[] compressed = new byte[compressedLen];
int rc = NativeMethods.BZ2_bzBuffToBuffCompress(compressed, ref compressedLen, uncompressed,
uncompressedLen, compressionLevel, 0, 0);
if(rc == BZ_OUTBUFF_FULL)
{
cstream = null;
return false;
}
else if(rc < 0)
{
Ice.CompressionException ex = new Ice.CompressionException("BZ2_bzBuffToBuffCompress failed");
ex.reason = getBZ2Error(rc);
throw ex;
}
//
// Don't bother if the compressed data is larger than the
// uncompressed data.
//
if(compressedLen >= uncompressedLen)
{
return false;
}
cstream = new BasicStream(instance_);
cstream.resize(headerSize + 4 + compressedLen, false);
cstream.pos(0);
//
// Copy the header from the uncompressed stream to the
// compressed one.
//
cstream._buf.b.put(_buf.b.rawBytes(0, headerSize));
//
// Add the size of the uncompressed stream before the
// message body.
//
cstream.writeInt(size());
//
// Add the compressed message body.
//
cstream._buf.b.put(compressed, 0, compressedLen);
return true;
#endif
}
示例10: uncompress
public BasicStream uncompress(int headerSize)
{
#if MANAGED || COMPACT
return this;
#else
if(!_bzlibInstalled)
{
return this;
}
pos(headerSize);
int uncompressedSize = readInt();
if(uncompressedSize <= headerSize)
{
throw new Ice.IllegalMessageSizeException("compressed size <= header size");
}
int compressedLen = size() - headerSize - 4;
byte[] compressed = _buf.b.rawBytes(headerSize + 4, compressedLen);
int uncompressedLen = uncompressedSize - headerSize;
byte[] uncompressed = new byte[uncompressedLen];
int rc = NativeMethods.BZ2_bzBuffToBuffDecompress(uncompressed, ref uncompressedLen, compressed,
compressedLen, 0, 0);
if(rc < 0)
{
Ice.CompressionException ex = new Ice.CompressionException("BZ2_bzBuffToBuffDecompress failed");
ex.reason = getBZ2Error(rc);
throw ex;
}
BasicStream ucStream = new BasicStream(instance_);
ucStream.resize(uncompressedSize, false);
ucStream.pos(0);
ucStream._buf.b.put(_buf.b.rawBytes(0, headerSize));
ucStream._buf.b.put(uncompressed, 0, uncompressedLen);
return ucStream;
#endif
}