This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import shared | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 230, height: 21)) | |
label.center = CGPoint(x: 160, y: 285) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.kotlinmultiplatformdemo | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.widget.TextView | |
import xyz.vivekc.shared.getDate | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.shared | |
import platform.Foundation.NSDate | |
actual fun getCurrentDate() = NSDate().toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.shared | |
import java.util.* | |
actual fun getCurrentDate() = Date().toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.shared | |
//Mark the function dependent on platform implementation to be `expect` | |
expect fun getCurrentDate(): String | |
//This is the function which would be called by the Android or iOS app | |
fun getDate(): String { | |
return "Today's Date is ${getCurrentDate()}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class SignallingClientKotlin { | |
internal interface SignalingInterface { | |
fun onRemoteHangUp(msg: String) | |
fun onOfferReceived(data: JSONObject) | |
fun onAnswerReceived(data: JSONObject) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityKotlin : AppCompatActivity(), View.OnClickListener, SignallingClientKotlin.SignalingInterface { | |
private val rootEglBase by lazy { EglBase.create() } | |
private val peerConnectionFactory: PeerConnectionFactory by lazy { | |
//Initialize PeerConnectionFactory globals. | |
val initializationOptions = PeerConnectionFactory.InitializationOptions.builder(this) | |
.setEnableVideoHwAcceleration(true) | |
.createInitializationOptions() | |
PeerConnectionFactory.initialize(initializationOptions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SignallingClient { | |
private static SignallingClient instance; | |
private String roomName = null; | |
private Socket socket; | |
boolean isChannelReady = false; | |
boolean isInitiator = false; | |
boolean isStarted = false; | |
private SignalingInterface callback; | |
//This piece of code should not go into production!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity implements View.OnClickListener, SignallingClient.SignalingInterface { | |
PeerConnectionFactory peerConnectionFactory; | |
MediaConstraints audioConstraints; | |
MediaConstraints videoConstraints; | |
MediaConstraints sdpConstraints; | |
VideoSource videoSource; | |
VideoTrack localVideoTrack; | |
AudioSource audioSource; | |
AudioTrack localAudioTrack; |
NewerOlder