inMemory.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import { Transport } from './shared/transport.js';
  2. import { JSONRPCMessage, RequestId } from './types.js';
  3. import { AuthInfo } from './server/auth/types.js';
  4. /**
  5. * In-memory transport for creating clients and servers that talk to each other within the same process.
  6. */
  7. export declare class InMemoryTransport implements Transport {
  8. private _otherTransport?;
  9. private _messageQueue;
  10. onclose?: () => void;
  11. onerror?: (error: Error) => void;
  12. onmessage?: (message: JSONRPCMessage, extra?: {
  13. authInfo?: AuthInfo;
  14. }) => void;
  15. sessionId?: string;
  16. /**
  17. * Creates a pair of linked in-memory transports that can communicate with each other. One should be passed to a Client and one to a Server.
  18. */
  19. static createLinkedPair(): [InMemoryTransport, InMemoryTransport];
  20. start(): Promise<void>;
  21. close(): Promise<void>;
  22. /**
  23. * Sends a message with optional auth info.
  24. * This is useful for testing authentication scenarios.
  25. */
  26. send(message: JSONRPCMessage, options?: {
  27. relatedRequestId?: RequestId;
  28. authInfo?: AuthInfo;
  29. }): Promise<void>;
  30. }
  31. //# sourceMappingURL=inMemory.d.ts.map