---
title: "init(opcode:)"
framework: network
role: symbol
role_heading: Initializer
path: "network/nwprotocolwebsocket/metadata/init(opcode:)"
---

# init(opcode:)

Initializes a WebSocket message with a specific type code.

## Declaration

```swift
init(opcode: NWProtocolWebSocket.Opcode)
```

## See Also

### Sending Messages

- [NWProtocolWebSocket.Opcode](network/nwprotocolwebsocket/opcode.md)
- [setPongHandler(_:handler:)](network/nwprotocolwebsocket/metadata/setponghandler(_:handler:).md)
- [closeCode](network/nwprotocolwebsocket/metadata/closecode.md)
- [NWProtocolWebSocket.CloseCode](network/nwprotocolwebsocket/closecode.md)
