/// <summary> /// Responds with a part of the result set of a query made via the /// <see cref="ProtocolConstants.Query"/> Query. /// </summary> /// <param name="dispatchId">The number we need to respond with.</param> /// <param name="command"></param> /// <returns></returns> private byte[] ResultSection(int dispatchId, byte[] command) { int resultId = ByteBuffer.ReadInt4(command, 8); int rowNumber = ByteBuffer.ReadInt4(command, 12); int rowCount = ByteBuffer.ReadInt4(command, 16); try { // Get the result part... ResultPart block = dbInterface.GetResultPart(resultId, rowNumber, rowCount); MemoryStream output = new MemoryStream(); BinaryWriter writer = new BinaryWriter(output, Encoding.Unicode); writer.Write(dispatchId); writer.Write(ProtocolConstants.Success); // Send the contents of the result set. // HACK - Work out column count by dividing number of entries in block // by number of rows. int colCount = block.Count / rowCount; writer.Write(colCount); int bsize = block.Count; for (int index = 0; index < bsize; ++index) { ObjectTransfer.WriteTo(writer, block[index]); } writer.Flush(); return(output.ToArray()); } catch (DataException e) { return(Exception(dispatchId, e)); } }
protected virtual void OnWinkDefinitionReceived(object sender, WinkEventArgs e) { if (!autoRequestObjects) { return; } MSNObject existing = MSNObjectCatalog.GetInstance().Get(e.Wink.CalculateChecksum()); if (existing == null) { // create a session and send the invitation ObjectTransfer winkTransfer = nsMessageHandler.P2PHandler.RequestMsnObject(e.Sender, e.Wink); winkTransfer.TransferAborted += (winkTransfer_TransferAborted); winkTransfer.TransferFinished += (winkTransfer_TransferFinished); MSNObjectCatalog.GetInstance().Add(e.Wink); if (WinkDefinitionReceived != null) { WinkDefinitionReceived(this, e); } } else { if (WinkDefinitionReceived != null) { WinkDefinitionReceived(this, new WinkEventArgs(e.Sender, existing as Wink, e.RoutingInfo)); } //If exists, fire the event. OnWinkReceived(this, new WinkEventArgs(e.Sender, existing as Wink, e.RoutingInfo)); } }
public ObjectTransfer RequestMsnObject(Contact remoteContact, MSNObject msnObject) { ObjectTransfer objectTransferApp = new ObjectTransfer(msnObject, remoteContact); AddTransfer(objectTransferApp); return(objectTransferApp); }
private void winkTransfer_TransferAborted(object objectTransfer, ContactEventArgs e) { ObjectTransfer session = objectTransfer as ObjectTransfer; session.TransferAborted -= (winkTransfer_TransferAborted); Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Wink aborted", GetType().Name); }
private void winkTransfer_TransferFinished(object objectTransfer, EventArgs e) { ObjectTransfer session = objectTransfer as ObjectTransfer; session.TransferFinished -= (winkTransfer_TransferFinished); Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Wink received", GetType().Name); OnWinkReceived(this, new WinkEventArgs(session.Remote, session.Object as Wink, null)); }
private void emoticonTransfer_TransferFinished(object objectTransfer, EventArgs e) { ObjectTransfer session = objectTransfer as ObjectTransfer; session.TransferFinished -= (emoticonTransfer_TransferFinished); Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Emoticon received", GetType().Name); Emoticon emoticon = session.Object as Emoticon; emoticon.DataReady = true; OnEmoticonReceived(this, new EmoticonArrivedEventArgs(session.Remote, emoticon, null, null)); }
protected virtual void OnEmoticonDefinitionReceived(object sender, EmoticonDefinitionEventArgs e) { if (!autoRequestObjects) { return; } MSNObject existing = MSNObjectCatalog.GetInstance().Get(e.Emoticon.CalculateChecksum()); if (existing == null) { e.Sender.Emoticons[e.Emoticon.Sha] = e.Emoticon; // create a session and send the invitation ObjectTransfer emoticonTransfer = nsMessageHandler.P2PHandler.RequestMsnObject(e.Sender, e.Emoticon); emoticonTransfer.TransferAborted += (emoticonTransfer_TransferAborted); emoticonTransfer.TransferFinished += (emoticonTransfer_TransferFinished); MSNObjectCatalog.GetInstance().Add(e.Emoticon); if (EmoticonDefinitionReceived != null) { EmoticonDefinitionReceived(this, e); } } else { if (EmoticonDefinitionReceived != null) { EmoticonDefinitionReceived(this, e); } Emoticon existingEmoticon = existing as Emoticon; //If exists and data were ready, fire the event. if (existingEmoticon.DataReady) { OnEmoticonReceived(this, new EmoticonArrivedEventArgs(e.Sender, existingEmoticon, null, e.RoutingInfo)); } else { Trace.WriteLineIf(Settings.TraceSwitch.TraceWarning, "An emoticon definition has been received, but the emoticon data were not yet completed."); } } }