
system.net.quic.QuicConnection Maven / Gradle / Ivy
/*
* MIT License
*
* Copyright (c) 2023 MASES s.r.l.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**************************************************************************************
*
* This code was generated from a template using JCOReflector
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
*
*************************************************************************************/
package system.net.quic;
import org.mases.jcobridge.*;
import org.mases.jcobridge.netreflection.*;
import java.util.ArrayList;
// Import section
import system.net.EndPoint;
import system.net.security.SslClientAuthenticationOptions;
import system.net.IPEndPoint;
import system.net.quic.implementations.QuicImplementationProvider;
import system.net.quic.QuicClientConnectionOptions;
import system.net.quic.QuicStream;
import system.threading.tasks.ValueTask;
import system.threading.CancellationToken;
import system.net.security.SslApplicationProtocol;
import system.security.cryptography.x509certificates.X509Certificate;
/**
* The base .NET class managing System.Net.Quic.QuicConnection, System.Net.Quic, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
*
*
* .NET documentation at https://docs.microsoft.com/en-us/dotnet/api/System.Net.Quic.QuicConnection
*
*
* Powered by JCOBridge: more info at https://www.jcobridge.com
*/
public class QuicConnection extends NetObject implements AutoCloseable {
/**
* Fully assembly qualified name: System.Net.Quic, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
*/
public static final String assemblyFullName = "System.Net.Quic, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
/**
* Assembly name: System.Net.Quic
*/
public static final String assemblyShortName = "System.Net.Quic";
/**
* Qualified class name: System.Net.Quic.QuicConnection
*/
public static final String className = "System.Net.Quic.QuicConnection";
static JCOBridge bridge = JCOBridgeInstance.getInstance(assemblyFullName);
/**
* The type managed from JCOBridge. See {@link JCType}
*/
public static JCType classType = createType();
static JCEnum enumInstance = null;
JCObject classInstance = null;
static JCType createType() {
try {
String classToCreate = className + ", "
+ (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Creating %s", classToCreate);
JCType typeCreated = bridge.GetType(classToCreate);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Created: %s",
(typeCreated != null) ? typeCreated.toString() : "Returned null value");
return typeCreated;
} catch (JCException e) {
JCOReflector.writeLog(e);
return null;
}
}
void addReference(String ref) throws Throwable {
try {
bridge.AddReference(ref);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
/**
* Internal constructor. Use with caution
*/
public QuicConnection(java.lang.Object instance) throws Throwable {
super(instance);
if (instance instanceof JCObject) {
classInstance = (JCObject) instance;
} else
throw new Exception("Cannot manage object, it is not a JCObject");
}
public String getJCOAssemblyName() {
return assemblyFullName;
}
public String getJCOClassName() {
return className;
}
public String getJCOObjectName() {
return className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
}
public java.lang.Object getJCOInstance() {
return classInstance;
}
public void setJCOInstance(JCObject instance) {
classInstance = instance;
super.setJCOInstance(classInstance);
}
public JCType getJCOType() {
return classType;
}
/**
* Try to cast the {@link IJCOBridgeReflected} instance into {@link QuicConnection}, a cast assert is made to check if types are compatible.
* @param from {@link IJCOBridgeReflected} instance to be casted
* @return {@link QuicConnection} instance
* @throws java.lang.Throwable in case of error during cast operation
*/
public static QuicConnection cast(IJCOBridgeReflected from) throws Throwable {
NetType.AssertCast(classType, from);
return new QuicConnection(from.getJCOInstance());
}
// Constructors section
public QuicConnection() throws Throwable {
}
public QuicConnection(EndPoint remoteEndPoint, SslClientAuthenticationOptions sslClientAuthenticationOptions, IPEndPoint localEndPoint) throws Throwable {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(remoteEndPoint == null ? null : remoteEndPoint.getJCOInstance(), sslClientAuthenticationOptions == null ? null : sslClientAuthenticationOptions.getJCOInstance(), localEndPoint == null ? null : localEndPoint.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public QuicConnection(QuicImplementationProvider implementationProvider, EndPoint remoteEndPoint, SslClientAuthenticationOptions sslClientAuthenticationOptions, IPEndPoint localEndPoint) throws Throwable {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(implementationProvider == null ? null : implementationProvider.getJCOInstance(), remoteEndPoint == null ? null : remoteEndPoint.getJCOInstance(), sslClientAuthenticationOptions == null ? null : sslClientAuthenticationOptions.getJCOInstance(), localEndPoint == null ? null : localEndPoint.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public QuicConnection(QuicImplementationProvider implementationProvider, QuicClientConnectionOptions options) throws Throwable {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(implementationProvider == null ? null : implementationProvider.getJCOInstance(), options == null ? null : options.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public QuicConnection(QuicClientConnectionOptions options) throws Throwable {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(options == null ? null : options.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Methods section
public int GetRemoteAvailableBidirectionalStreamCount() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (int)classInstance.Invoke("GetRemoteAvailableBidirectionalStreamCount");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public int GetRemoteAvailableUnidirectionalStreamCount() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (int)classInstance.Invoke("GetRemoteAvailableUnidirectionalStreamCount");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public QuicStream OpenBidirectionalStream() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objOpenBidirectionalStream = (JCObject)classInstance.Invoke("OpenBidirectionalStream");
return new QuicStream(objOpenBidirectionalStream);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public QuicStream OpenUnidirectionalStream() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objOpenUnidirectionalStream = (JCObject)classInstance.Invoke("OpenUnidirectionalStream");
return new QuicStream(objOpenUnidirectionalStream);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ValueTask CloseAsync(long errorCode, CancellationToken cancellationToken) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objCloseAsync = (JCObject)classInstance.Invoke("CloseAsync", errorCode, cancellationToken == null ? null : cancellationToken.getJCOInstance());
return new ValueTask(objCloseAsync);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ValueTask ConnectAsync(CancellationToken cancellationToken) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objConnectAsync = (JCObject)classInstance.Invoke("ConnectAsync", cancellationToken == null ? null : cancellationToken.getJCOInstance());
return new ValueTask(objConnectAsync);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ValueTask WaitForAvailableBidirectionalStreamsAsync(CancellationToken cancellationToken) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objWaitForAvailableBidirectionalStreamsAsync = (JCObject)classInstance.Invoke("WaitForAvailableBidirectionalStreamsAsync", cancellationToken == null ? null : cancellationToken.getJCOInstance());
return new ValueTask(objWaitForAvailableBidirectionalStreamsAsync);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ValueTask WaitForAvailableUnidirectionalStreamsAsync(CancellationToken cancellationToken) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objWaitForAvailableUnidirectionalStreamsAsync = (JCObject)classInstance.Invoke("WaitForAvailableUnidirectionalStreamsAsync", cancellationToken == null ? null : cancellationToken.getJCOInstance());
return new ValueTask(objWaitForAvailableUnidirectionalStreamsAsync);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void Dispose() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Dispose");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void close() throws Exception {
try {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Dispose");
}
catch (JCNativeException jcne) {
throw translateException(jcne);
}
} catch (Throwable t) {
throw new Exception(t);
}
}
// Properties section
public boolean getConnected() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("Connected");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public EndPoint getRemoteEndPoint() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("RemoteEndPoint");
return new EndPoint(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public IPEndPoint getLocalEndPoint() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("LocalEndPoint");
return new IPEndPoint(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public SslApplicationProtocol getNegotiatedApplicationProtocol() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("NegotiatedApplicationProtocol");
return new SslApplicationProtocol(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public X509Certificate getRemoteCertificate() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("RemoteCertificate");
return new X509Certificate(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Instance Events section
}