All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bugvm.apple.gamekit.GKSession Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 * Copyright (C) 2013-2015 RoboVM AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bugvm.apple.gamekit;

/**/
import java.io.*;
import java.nio.*;
import java.util.*;
import com.bugvm.objc.*;
import com.bugvm.objc.annotation.*;
import com.bugvm.objc.block.*;
import com.bugvm.rt.*;
import com.bugvm.rt.annotation.*;
import com.bugvm.rt.bro.*;
import com.bugvm.rt.bro.annotation.*;
import com.bugvm.rt.bro.ptr.*;
import com.bugvm.apple.foundation.*;
import com.bugvm.apple.uikit.*;
/**/

/**/
/**
 * @since Available in iOS 3.0 and later.
 * @deprecated Deprecated in iOS 7.0.
 */
@Deprecated
/**/
/**/@Library("GameKit") @NativeClass/**/
/**/public/**/ class /**/GKSession/**/ 
    extends /**/NSObject/**/ 
    /**//**/ {

    public interface DataReceiveHandler {
        void onReceive(NSData data, String peer, GKSession session);
    }
    
    private static final Selector handleDataReceive = Selector.register("receiveData:fromPeer:inSession:context:");
    private static class ListenerWrapper extends NSObject {
        private final DataReceiveHandler listener;
        private ListenerWrapper(DataReceiveHandler listener) {
            this.listener = listener;
        }
        @Method(selector = "handleDataReceive")
        private void handleDataReceive(NSData data, String peer, GKSession session, @Pointer long context) {
            listener.onReceive(data, peer, session);
        }
    }
    
    /**/public static class GKSessionPtr extends Ptr {}/**/
    /**/static { ObjCRuntime.bind(GKSession.class); }/**/
    /**//**/
    /**/
    public GKSession() {}
    protected GKSession(SkipInit skipInit) { super(skipInit); }
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    public GKSession(String sessionID, String name, GKSessionMode mode) { super((SkipInit) null); initObject(init(sessionID, name, mode)); }
    /**/
    /**/
    @Property(selector = "delegate")
    public native GKSessionDelegate getDelegate();
    @Property(selector = "setDelegate:", strongRef = true)
    public native void setDelegate(GKSessionDelegate v);
    @Property(selector = "sessionID")
    public native String getSessionID();
    @Property(selector = "displayName")
    public native String getDisplayName();
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    @Property(selector = "sessionMode")
    public native GKSessionMode getSessionMode();
    @Property(selector = "peerID")
    public native String getPeerID();
    @Property(selector = "isAvailable")
    public native boolean isAvailable();
    @Property(selector = "setAvailable:")
    public native void setAvailable(boolean v);
    @Property(selector = "disconnectTimeout")
    public native double getDisconnectTimeout();
    @Property(selector = "setDisconnectTimeout:")
    public native void setDisconnectTimeout(double v);
    /**/
    /**//**/
    public void setDataReceiveHandler(DataReceiveHandler handler) {
        if (handler == null) {
            throw new NullPointerException("handler");
        }
        ListenerWrapper l = new ListenerWrapper(handler);
        setDataReceiveHandler(l, 0);
        addStrongRef(l);
    }
    /**/
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    @Method(selector = "initWithSessionID:displayName:sessionMode:")
    protected native @Pointer long init(String sessionID, String name, GKSessionMode mode);
    @Method(selector = "displayNameForPeer:")
    public native String getDisplayName(String peerID);
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    public boolean sendData(NSData data, @com.bugvm.rt.bro.annotation.Marshaler(NSArray.AsStringListMarshaler.class) List peers, GKSendDataMode mode) throws NSErrorException {
       NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
       boolean result = sendData(data, peers, mode, ptr);
       if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
       return result;
    }
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    @Method(selector = "sendData:toPeers:withDataMode:error:")
    private native boolean sendData(NSData data, @com.bugvm.rt.bro.annotation.Marshaler(NSArray.AsStringListMarshaler.class) List peers, GKSendDataMode mode, NSError.NSErrorPtr error);
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    public boolean sendDataToAllPeers(NSData data, GKSendDataMode mode) throws NSErrorException {
       NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
       boolean result = sendDataToAllPeers(data, mode, ptr);
       if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
       return result;
    }
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    @Method(selector = "sendDataToAllPeers:withDataMode:error:")
    private native boolean sendDataToAllPeers(NSData data, GKSendDataMode mode, NSError.NSErrorPtr error);
    @Method(selector = "setDataReceiveHandler:withContext:")
    protected native void setDataReceiveHandler(NSObject handler, @Pointer long context);
    @Method(selector = "connectToPeer:withTimeout:")
    public native void connect(String peerID, double timeout);
    @Method(selector = "cancelConnectToPeer:")
    public native void cancelConnect(String peerID);
    public boolean acceptConnection(String peerID) throws NSErrorException {
       NSError.NSErrorPtr ptr = new NSError.NSErrorPtr();
       boolean result = acceptConnection(peerID, ptr);
       if (ptr.get() != null) { throw new NSErrorException(ptr.get()); }
       return result;
    }
    @Method(selector = "acceptConnectionFromPeer:error:")
    private native boolean acceptConnection(String peerID, NSError.NSErrorPtr error);
    @Method(selector = "denyConnectionFromPeer:")
    public native void denyConnection(String peerID);
    @Method(selector = "disconnectPeerFromAllPeers:")
    public native void disconnectPeer(String peerID);
    @Method(selector = "disconnectFromAllPeers")
    public native void disconnectFromAllPeers();
    /**
     * @since Available in iOS 3.0 and later.
     * @deprecated Deprecated in iOS 7.0.
     */
    @Deprecated
    @Method(selector = "peersWithConnectionState:")
    public native @com.bugvm.rt.bro.annotation.Marshaler(NSArray.AsStringListMarshaler.class) List getPeers(GKPeerConnectionState state);
    /**/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy