目录
目录README.md

Build Status License Platforms Documentation

JSONRPC

A simple Swift library for JSON-RPC. It features strong type-safety and makes no assumptions about the underlying transport stream.

Integration

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/ChimeHQ/JSONRPC")
]

Classes

ProtocolTransport

This is the core class for using the protocol. It supports sending and receiving generic messages and notifications, as well as responding to protocol-level errors.

// takes a struct with all of the handler functions needed.
public func setHandlers(_ handlers: Handlers)

public func sendDataRequest<T>(_ params: T, method: String, responseHandler: @escaping (DataResult) -> Void) where T: Encodable
public func sendDataRequest<T>(_ params: T, method: String) async throws -> (AnyJSONRPCResponse, Data) where T: Encodable

public func sendRequest<T, U>(_ params: T, method: String, responseHandler: @escaping (ResponseResult<U>) -> Void) where T: Encodable, U: Decodable
public func sendRequest<T, U>(_ params: T, method: String) async throws -> JSONRPCResponse<U> where T: Encodable, U: Decodable

public func sendNotification<T>(_ params: T?, method: String, completionHandler: @escaping (Error?) -> Void = {_ in }) where T: Encodable
public func sendNotification<T>(_ params: T?, method: String) async throws where T: Encodable

StdioDataTransport

This is a concrete implementation of the DataTransport protocol, which passes data across stdio.

MessageTransport

This gives you a way to frame/delimit messages in the wire protocol. It is optional, in case you don’t need/want to use that functionality. It relies on the MessageProtocol protocol.

SeperatedHTTPHeaderMessageProtocol

A concrete MessageProtocol that uses HTTP headers. It requires at least Content-Length, and by default expects all fields to be separated by \r\n.

Suggestions or Feedback

We’d love to hear from you! Get in touch via an issue or pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

关于
148.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号